Debugging Javascript InRails

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging Javascript InRails

David Merrick
Hi I want to know how to debug Javascript in Rails

I have made a games program in Rails which works fine but when I try and extend the final  app in https://www.railstutorial.org/

withe corresponding files the Javascript dosen't work properly.

New routes file is below

Rails.application.routes.draw do
  root 'static_pages#home'
  get 'password_resets/new'
  get 'password_resets/edit'
  get 'sessions/new'
  get 'users/new'  
  get '/help',    to: 'static_pages#help'
  get '/about',   to: 'static_pages#about'
  get '/contact', to: 'static_pages#contact'
  get  '/signup',  to: 'users#new'
  post '/signup',  to: 'users#create'
  get    '/login',   to: 'sessions#new'
  post   '/login',   to: 'sessions#create'
  delete '/logout',  to: 'sessions#destroy'
  get 'game/BlackJack'
  get 'game/Poker'
  get 'game/Yaghtzee'
  get 'game/MasterMind'
  get '/blackjack',    to: 'game#BlackJack'
  get '/poker',    to: 'game#Poker'
  get '/yaghtzee',    to: 'game#Yaghtzee'
  get '/mastermind',    to: 'game#MasterMind'
  
  resources :users
  resources :game, only: [:BlackJack, :Poker, :Yaghtzee, :MasterMind]
  resources :account_activations, only: [:edit]
  resources :password_resets,     only: [:new, :create, :edit, :update]
end

Working routes file in games program

Rails.application.routes.draw do
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  root 'static_pages#home'  
  get 'game/BlackJack'
  get 'game/Poker'
  get 'game/Yaghtzee'
  get 'game/MasterMind'
  get '/blackjack',    to: 'game#BlackJack'
  get '/poker',    to: 'game#Poker'
  get '/yaghtzee',    to: 'game#Yaghtzee'
  get '/mastermind',    to: 'game#MasterMind'
  
end

Any ideas as to why the Javascript files are only partly working is welcome

Cheers Dave

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/55525f1d-310f-4337-9d3d-6bbe7f8081a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Javascript InRails

Walter Lee Davis

> On Jul 9, 2018, at 12:59 AM, David Merrick <[hidden email]> wrote:
>
> Hi I want to know how to debug Javascript in Rails
>
> I have made a games program in Rails which works fine but when I try and extend the final  app in https://www.railstutorial.org/
>
> withe corresponding files the Javascript dosen't work properly.

You're going to have to get a whole lot more specific about what "doesn't work properly" means. JavaScript could fail for a lot of its own reasons, and then you could have a flaw in your Ruby code that sends it values it isn't prepared to work with.

>
> New routes file is below
>
> Rails.application.routes.draw do
>   root 'static_pages#home'
>   get 'password_resets/new'
>   get 'password_resets/edit'
>   get 'sessions/new'
>   get 'users/new'  
>   get '/help',    to: 'static_pages#help'
>   get '/about',   to: 'static_pages#about'
>   get '/contact', to: 'static_pages#contact'
>   get  '/signup',  to: 'users#new'
>   post '/signup',  to: 'users#create'
>   get    '/login',   to: 'sessions#new'
>   post   '/login',   to: 'sessions#create'
>   delete '/logout',  to: 'sessions#destroy'
>   get 'game/BlackJack'
>   get 'game/Poker'
>   get 'game/Yaghtzee'
>   get 'game/MasterMind'
>   get '/blackjack',    to: 'game#BlackJack'
>   get '/poker',    to: 'game#Poker'
>   get '/yaghtzee',    to: 'game#Yaghtzee'
>   get '/mastermind',    to: 'game#MasterMind'
>  
>   resources :users
>   resources :game, only: [:BlackJack, :Poker, :Yaghtzee, :MasterMind]
>   resources :account_activations, only: [:edit]
>   resources :password_resets,     only: [:new, :create, :edit, :update]
> end
>
> Working routes file in games program
>
> Rails.application.routes.draw do
>   # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
>   root 'static_pages#home'  
>   get 'game/BlackJack'
>   get 'game/Poker'
>   get 'game/Yaghtzee'
>   get 'game/MasterMind'
>   get '/blackjack',    to: 'game#BlackJack'
>   get '/poker',    to: 'game#Poker'
>   get '/yaghtzee',    to: 'game#Yaghtzee'
>   get '/mastermind',    to: 'game#MasterMind'
>  
> end
>
> Any ideas as to why the Javascript files are only partly working is welcome

Checklist:

1. Are your JavaScript observers aware of TurboLinks, and are they waiting for the `turbolinks:load` event before trying to listen to events?

2. Are you using the Asset Pipeline, and are your scripts being concatenated in alphabetical order (and do they care about their order), or are you specifying their load order in application.js?

3. Do you have tests of your Ruby and your JavaScript? Do you know that they all work independent of one another?

Walter

>
> Cheers Dave
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/55525f1d-310f-4337-9d3d-6bbe7f8081a3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56C62EAE-1429-4090-BD3E-9BAA6423BC02%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Javascript InRails

David Merrick
Problem fixed I needed to recheck some files

On Tue, Jul 10, 2018 at 1:26 AM, Walter Lee Davis <[hidden email]> wrote:

> On Jul 9, 2018, at 12:59 AM, David Merrick <[hidden email]> wrote:
>
> Hi I want to know how to debug Javascript in Rails
>
> I have made a games program in Rails which works fine but when I try and extend the final  app in https://www.railstutorial.org/
>
> withe corresponding files the Javascript dosen't work properly.

You're going to have to get a whole lot more specific about what "doesn't work properly" means. JavaScript could fail for a lot of its own reasons, and then you could have a flaw in your Ruby code that sends it values it isn't prepared to work with.

>
> New routes file is below
>
> Rails.application.routes.draw do
>   root 'static_pages#home'
>   get 'password_resets/new'
>   get 'password_resets/edit'
>   get 'sessions/new'
>   get 'users/new' 
>   get '/help',    to: 'static_pages#help'
>   get '/about',   to: 'static_pages#about'
>   get '/contact', to: 'static_pages#contact'
>   get  '/signup',  to: 'users#new'
>   post '/signup',  to: 'users#create'
>   get    '/login',   to: 'sessions#new'
>   post   '/login',   to: 'sessions#create'
>   delete '/logout',  to: 'sessions#destroy'
>   get 'game/BlackJack'
>   get 'game/Poker'
>   get 'game/Yaghtzee'
>   get 'game/MasterMind'
>   get '/blackjack',    to: 'game#BlackJack'
>   get '/poker',    to: 'game#Poker'
>   get '/yaghtzee',    to: 'game#Yaghtzee'
>   get '/mastermind',    to: 'game#MasterMind'
>   
>   resources :users
>   resources :game, only: [:BlackJack, :Poker, :Yaghtzee, :MasterMind]
>   resources :account_activations, only: [:edit]
>   resources :password_resets,     only: [:new, :create, :edit, :update]
> end
>
> Working routes file in games program
>
> Rails.application.routes.draw do
>   # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
>   root 'static_pages#home' 
>   get 'game/BlackJack'
>   get 'game/Poker'
>   get 'game/Yaghtzee'
>   get 'game/MasterMind'
>   get '/blackjack',    to: 'game#BlackJack'
>   get '/poker',    to: 'game#Poker'
>   get '/yaghtzee',    to: 'game#Yaghtzee'
>   get '/mastermind',    to: 'game#MasterMind'
>   
> end
>
> Any ideas as to why the Javascript files are only partly working is welcome

Checklist:

1. Are your JavaScript observers aware of TurboLinks, and are they waiting for the `turbolinks:load` event before trying to listen to events?

2. Are you using the Asset Pipeline, and are your scripts being concatenated in alphabetical order (and do they care about their order), or are you specifying their load order in application.js?

3. Do you have tests of your Ruby and your JavaScript? Do you know that they all work independent of one another?

Walter

>
> Cheers Dave
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To post to this group, send email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/55525f1d-310f-4337-9d3d-6bbe7f8081a3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/56C62EAE-1429-4090-BD3E-9BAA6423BC02%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.



--
Dave Merrick

Tutor Invercargill

Website http://tutorinvercargill.co.nz/

Email [hidden email]

Ph   03 216 2053

Cell 027 3089 169

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKa%2B4buWLybLf2rwk_DzLg77MRE648KnyVHxz%3DCibgcxaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.