Sumit Srivastava
2012-Nov-30 04:51 UTC
Issue with passing parameter to action using link_to
Hi, I have a controller named Users with index action. def index puts "************* #{params[:city]}" ... ... end From the view, link_to(:city, list_users_with_city_path(:city => city.name)) But when I click on this link, it doesn''t prints out anything for the params. All the "*" are being printed. The url in the browser displays, localhost:3000/users?city=delhi Instead when I create a new route, get ''/users/:city'' => ''users#index'', :as => list_users_with_city This works fine. I get proper output. What could be the problem? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Nov-30 05:11 UTC
Re: Issue with passing parameter to action using link_to
On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I have a controller named Users with index action. > > def index > puts "************* #{params[:city]}" > ... > ... > end > > From the view, > link_to(:city, list_users_with_city_path(:city => city.name)) >You implied below that list_users_with_city_path is not yet defined at this point so why is it not giving any errors? where did you get list_user_with_city_path if you haven''t defined it in the routed yet?> But when I click on this link, it doesn''t prints out anything for the > params. All the "*" are being printed. The url in the browser displays, > > localhost:3000/users?city=delhi > > Instead when I create a new route, get ''/users/:city'' => ''users#index'', > :as => list_users_with_city > This works fine. I get proper output.> What could be the problem? > > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Nov-30 05:16 UTC
Re: Issue with passing parameter to action using link_to
On 30 November 2012 10:41, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < > sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hi, >> >> I have a controller named Users with index action. >> >> def index >> puts "************* #{params[:city]}" >> ... >> ... >> end >> >> From the view, >> link_to(:city, list_users_with_city_path(:city => city.name)) >> > > You implied below that list_users_with_city_path is not yet defined > at this point so why is it not giving any errors? where did you > get list_user_with_city_path if you haven''t defined it in the routed yet? >Wrote this by mistake. I use it this way after defining the path. What doesn''t works is, link_to(:city, users(:city => city.name) And this is not giving any errors but nothing is received in the index action.> > >> But when I click on this link, it doesn''t prints out anything for the >> params. All the "*" are being printed. The url in the browser displays, >> >> localhost:3000/users?city=delhi >> >> Instead when I create a new route, get ''/users/:city'' => ''users#index'', >> :as => list_users_with_city >> This works fine. I get proper output. > > >> What could be the problem? >> >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Nov-30 05:25 UTC
Re: Issue with passing parameter to action using link_to
On Fri, Nov 30, 2012 at 1:16 PM, sumit srivastava < sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 30 November 2012 10:41, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> >> On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < >> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> Hi, >>> >>> I have a controller named Users with index action. >>> >>> def index >>> puts "************* #{params[:city]}" >>> ... >>> ... >>> end >>> >>> From the view, >>> link_to(:city, list_users_with_city_path(:city => city.name)) >>> >> >> You implied below that list_users_with_city_path is not yet defined >> at this point so why is it not giving any errors? where did you >> get list_user_with_city_path if you haven''t defined it in the routed yet? >> > > Wrote this by mistake. I use it this way after defining the path. What > doesn''t works is, > > link_to(:city, users(:city => city.name) > And this is not giving any errors but nothing is received in the index > action. >use users_path. I''m not sure why it''s not giving any errors.> > > >> >> >>> But when I click on this link, it doesn''t prints out anything for the >>> params. All the "*" are being printed. The url in the browser displays, >>> >>> localhost:3000/users?city=delhi >>> >>> Instead when I create a new route, get ''/users/:city'' => ''users#index'', >>> :as => list_users_with_city >>> This works fine. I get proper output. >> >> >>> What could be the problem? >>> >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To view this discussion on the web visit >>> https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> ------------------------------------------------------------- >> visit my blog at http://jimlabs.heroku.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Nov-30 05:32 UTC
Re: Issue with passing parameter to action using link_to
On 30 November 2012 10:55, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Fri, Nov 30, 2012 at 1:16 PM, sumit srivastava < > sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 30 November 2012 10:41, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> >>> >>> >>> On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < >>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> Hi, >>>> >>>> I have a controller named Users with index action. >>>> >>>> def index >>>> puts "************* #{params[:city]}" >>>> ... >>>> ... >>>> end >>>> >>>> From the view, >>>> link_to(:city, list_users_with_city_path(:city => city.name)) >>>> >>> >>> You implied below that list_users_with_city_path is not yet defined >>> at this point so why is it not giving any errors? where did you >>> get list_user_with_city_path if you haven''t defined it in the routed yet? >>> >> >> Wrote this by mistake. I use it this way after defining the path. What >> doesn''t works is, >> >> link_to(:city, users(:city => city.name) >> And this is not giving any errors but nothing is received in the index >> action. >> > > use users_path. I''m not sure why it''s not giving any errors. >Ah! Again I typed wrong. Yes, this is what I used, users_path and seems like I also missed the closing bracket for link_to up here. Certainly, it gave errors without "path". So, with the correct syntax, link_to(:city, users_path(:city => city.name)), it didn''t work.> >> >> >> >>> >>> >>>> But when I click on this link, it doesn''t prints out anything for the >>>> params. All the "*" are being printed. The url in the browser displays, >>>> >>>> localhost:3000/users?city=delhi >>>> >>>> Instead when I create a new route, get ''/users/:city'' => ''users#index'', >>>> :as => list_users_with_city >>>> This works fine. I get proper output. >>> >>> >>>> What could be the problem? >>>> >>>> >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Talk" group. >>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> ------------------------------------------------------------- >>> visit my blog at http://jimlabs.heroku.com >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Nov-30 05:42 UTC
Re: Issue with passing parameter to action using link_to
On Fri, Nov 30, 2012 at 1:32 PM, sumit srivastava < sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 30 November 2012 10:55, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> >> On Fri, Nov 30, 2012 at 1:16 PM, sumit srivastava < >> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> On 30 November 2012 10:41, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> >>>> >>>> >>>> On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < >>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> Hi, >>>>> >>>>> I have a controller named Users with index action. >>>>> >>>>> def index >>>>> puts "************* #{params[:city]}" >>>>> ... >>>>> ... >>>>> end >>>>> >>>>> From the view, >>>>> link_to(:city, list_users_with_city_path(:city => city.name)) >>>>> >>>> >>>> You implied below that list_users_with_city_path is not yet defined >>>> at this point so why is it not giving any errors? where did you >>>> get list_user_with_city_path if you haven''t defined it in the routed >>>> yet? >>>> >>> >>> Wrote this by mistake. I use it this way after defining the path. What >>> doesn''t works is, >>> >>> link_to(:city, users(:city => city.name) >>> And this is not giving any errors but nothing is received in the index >>> action. >>> >> >> use users_path. I''m not sure why it''s not giving any errors. >> > > Ah! Again I typed wrong. Yes, this is what I used, users_path and seems > like I also missed the closing bracket for link_to up here. Certainly, it > gave errors without "path". > > So, with the correct syntax, link_to(:city, users_path(:city => city.name)), > it didn''t work. >i''m not sure why params[:city] isn''t set when you reach that puts statement. It may be caused by a number of things. Can you check if it really goes to the index action, you may have declared something on your routes that takes precedence over the users resources? Paste in the log after you click on the link and you routes file (everything before the resources :users line).> > >> >>> >>> >>> >>>> >>>> >>>>> But when I click on this link, it doesn''t prints out anything for the >>>>> params. All the "*" are being printed. The url in the browser displays, >>>>> >>>>> localhost:3000/users?city=delhi >>>>> >>>>> Instead when I create a new route, get ''/users/:city'' => >>>>> ''users#index'', :as => list_users_with_city >>>>> This works fine. I get proper output. >>>> >>>> >>>>> What could be the problem? >>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Ruby on Rails: Talk" group. >>>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> ------------------------------------------------------------- >>>> visit my blog at http://jimlabs.heroku.com >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Talk" group. >>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> ------------------------------------------------------------- >> visit my blog at http://jimlabs.heroku.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Nov-30 05:50 UTC
Re: Issue with passing parameter to action using link_to
If it were being directed to some other action, then *************** should not have been printed. And when I am trying to access this parameter from the view "index.html.haml", its value is printed exactly what is being passed. Regards Sumit Srivastava The power of imagination makes us infinite... On 30 November 2012 11:12, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Fri, Nov 30, 2012 at 1:32 PM, sumit srivastava < > sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 30 November 2012 10:55, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> >>> >>> >>> On Fri, Nov 30, 2012 at 1:16 PM, sumit srivastava < >>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> On 30 November 2012 10:41, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> >>>>> >>>>> >>>>> On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < >>>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I have a controller named Users with index action. >>>>>> >>>>>> def index >>>>>> puts "************* #{params[:city]}" >>>>>> ... >>>>>> ... >>>>>> end >>>>>> >>>>>> From the view, >>>>>> link_to(:city, list_users_with_city_path(:city => city.name)) >>>>>> >>>>> >>>>> You implied below that list_users_with_city_path is not yet defined >>>>> at this point so why is it not giving any errors? where did you >>>>> get list_user_with_city_path if you haven''t defined it in the routed >>>>> yet? >>>>> >>>> >>>> Wrote this by mistake. I use it this way after defining the path. What >>>> doesn''t works is, >>>> >>>> link_to(:city, users(:city => city.name) >>>> And this is not giving any errors but nothing is received in the index >>>> action. >>>> >>> >>> use users_path. I''m not sure why it''s not giving any errors. >>> >> >> Ah! Again I typed wrong. Yes, this is what I used, users_path and seems >> like I also missed the closing bracket for link_to up here. Certainly, it >> gave errors without "path". >> >> So, with the correct syntax, link_to(:city, users_path(:city => city.name)), >> it didn''t work. >> > > i''m not sure why params[:city] isn''t set when you reach that puts > statement. It may be caused by > a number of things. Can you check if it really goes to the index action, > you may have declared > something on your routes that takes precedence over the users resources? > Paste in the log after > you click on the link and you routes file (everything before the resources > :users line). > > >> >> >>> >>>> >>>> >>>> >>>>> >>>>> >>>>>> But when I click on this link, it doesn''t prints out anything for the >>>>>> params. All the "*" are being printed. The url in the browser displays, >>>>>> >>>>>> localhost:3000/users?city=delhi >>>>>> >>>>>> Instead when I create a new route, get ''/users/:city'' => >>>>>> ''users#index'', :as => list_users_with_city >>>>>> This works fine. I get proper output. >>>>> >>>>> >>>>>> What could be the problem? >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Ruby on Rails: Talk" group. >>>>>> To post to this group, send email to >>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. >>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> ------------------------------------------------------------- >>>>> visit my blog at http://jimlabs.heroku.com >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Ruby on Rails: Talk" group. >>>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Talk" group. >>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> ------------------------------------------------------------- >>> visit my blog at http://jimlabs.heroku.com >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Nov-30 06:09 UTC
Re: Issue with passing parameter to action using link_to
On Fri, Nov 30, 2012 at 1:50 PM, sumit srivastava < sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If it were being directed to some other action, then *************** > should not have been printed. And when I am trying to access this parameter > from the view "index.html.haml", its value is printed exactly what is being > passed. >You''re right but you may have the same kind of puts code in other parts of your file. We''re just making sure that it really is going to the index action. Try to use debugger instead of puts when you''re debugging. There may be times when you''re rendering the same template from a different action which is why the value is printed correctly.> > Regards > Sumit Srivastava > > The power of imagination makes us infinite... > > > > On 30 November 2012 11:12, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> >> On Fri, Nov 30, 2012 at 1:32 PM, sumit srivastava < >> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> On 30 November 2012 10:55, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> >>>> >>>> >>>> On Fri, Nov 30, 2012 at 1:16 PM, sumit srivastava < >>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> On 30 November 2012 10:41, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < >>>>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> I have a controller named Users with index action. >>>>>>> >>>>>>> def index >>>>>>> puts "************* #{params[:city]}" >>>>>>> ... >>>>>>> ... >>>>>>> end >>>>>>> >>>>>>> From the view, >>>>>>> link_to(:city, list_users_with_city_path(:city => city.name)) >>>>>>> >>>>>> >>>>>> You implied below that list_users_with_city_path is not yet defined >>>>>> at this point so why is it not giving any errors? where did you >>>>>> get list_user_with_city_path if you haven''t defined it in the routed >>>>>> yet? >>>>>> >>>>> >>>>> Wrote this by mistake. I use it this way after defining the path. What >>>>> doesn''t works is, >>>>> >>>>> link_to(:city, users(:city => city.name) >>>>> And this is not giving any errors but nothing is received in the index >>>>> action. >>>>> >>>> >>>> use users_path. I''m not sure why it''s not giving any errors. >>>> >>> >>> Ah! Again I typed wrong. Yes, this is what I used, users_path and seems >>> like I also missed the closing bracket for link_to up here. Certainly, it >>> gave errors without "path". >>> >>> So, with the correct syntax, link_to(:city, users_path(:city => >>> city.name)), it didn''t work. >>> >> >> i''m not sure why params[:city] isn''t set when you reach that puts >> statement. It may be caused by >> a number of things. Can you check if it really goes to the index action, >> you may have declared >> something on your routes that takes precedence over the users resources? >> Paste in the log after >> you click on the link and you routes file (everything before the >> resources :users line). >> >> >>> >>> >>>> >>>>> >>>>> >>>>> >>>>>> >>>>>> >>>>>>> But when I click on this link, it doesn''t prints out anything for >>>>>>> the params. All the "*" are being printed. The url in the browser displays, >>>>>>> >>>>>>> localhost:3000/users?city=delhi >>>>>>> >>>>>>> Instead when I create a new route, get ''/users/:city'' => >>>>>>> ''users#index'', :as => list_users_with_city >>>>>>> This works fine. I get proper output. >>>>>> >>>>>> >>>>>>> What could be the problem? >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Ruby on Rails: Talk" group. >>>>>>> To post to this group, send email to >>>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To view this discussion on the web visit >>>>>>> https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. >>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> ------------------------------------------------------------- >>>>>> visit my blog at http://jimlabs.heroku.com >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Ruby on Rails: Talk" group. >>>>>> To post to this group, send email to >>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>> >>>>>> >>>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Ruby on Rails: Talk" group. >>>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> ------------------------------------------------------------- >>>> visit my blog at http://jimlabs.heroku.com >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Talk" group. >>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> ------------------------------------------------------------- >> visit my blog at http://jimlabs.heroku.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Nov-30 06:50 UTC
Re: Issue with passing parameter to action using link_to
Verified it. Don''t have puts anywhere else. Regards Sumit Srivastava The power of imagination makes us infinite... On 30 November 2012 11:39, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Fri, Nov 30, 2012 at 1:50 PM, sumit srivastava < > sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> If it were being directed to some other action, then *************** >> should not have been printed. And when I am trying to access this parameter >> from the view "index.html.haml", its value is printed exactly what is being >> passed. >> > > You''re right but you may have the same kind of puts code in other parts of > your file. We''re just making > sure that it really is going to the index action. Try to use debugger > instead of puts when you''re debugging. > There may be times when you''re rendering the same template from a > different action which is why > the value is printed correctly. > > >> >> Regards >> Sumit Srivastava >> >> The power of imagination makes us infinite... >> >> >> >> On 30 November 2012 11:12, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> >>> >>> >>> On Fri, Nov 30, 2012 at 1:32 PM, sumit srivastava < >>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> On 30 November 2012 10:55, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> >>>>> >>>>> >>>>> On Fri, Nov 30, 2012 at 1:16 PM, sumit srivastava < >>>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> On 30 November 2012 10:41, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < >>>>>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> I have a controller named Users with index action. >>>>>>>> >>>>>>>> def index >>>>>>>> puts "************* #{params[:city]}" >>>>>>>> ... >>>>>>>> ... >>>>>>>> end >>>>>>>> >>>>>>>> From the view, >>>>>>>> link_to(:city, list_users_with_city_path(:city => city.name)) >>>>>>>> >>>>>>> >>>>>>> You implied below that list_users_with_city_path is not yet defined >>>>>>> at this point so why is it not giving any errors? where did you >>>>>>> get list_user_with_city_path if you haven''t defined it in the routed >>>>>>> yet? >>>>>>> >>>>>> >>>>>> Wrote this by mistake. I use it this way after defining the path. >>>>>> What doesn''t works is, >>>>>> >>>>>> link_to(:city, users(:city => city.name) >>>>>> And this is not giving any errors but nothing is received in the >>>>>> index action. >>>>>> >>>>> >>>>> use users_path. I''m not sure why it''s not giving any errors. >>>>> >>>> >>>> Ah! Again I typed wrong. Yes, this is what I used, users_path and seems >>>> like I also missed the closing bracket for link_to up here. Certainly, it >>>> gave errors without "path". >>>> >>>> So, with the correct syntax, link_to(:city, users_path(:city => >>>> city.name)), it didn''t work. >>>> >>> >>> i''m not sure why params[:city] isn''t set when you reach that puts >>> statement. It may be caused by >>> a number of things. Can you check if it really goes to the index >>> action, you may have declared >>> something on your routes that takes precedence over the users resources? >>> Paste in the log after >>> you click on the link and you routes file (everything before the >>> resources :users line). >>> >>> >>>> >>>> >>>>> >>>>>> >>>>>> >>>>>> >>>>>>> >>>>>>> >>>>>>>> But when I click on this link, it doesn''t prints out anything for >>>>>>>> the params. All the "*" are being printed. The url in the browser displays, >>>>>>>> >>>>>>>> localhost:3000/users?city=delhi >>>>>>>> >>>>>>>> Instead when I create a new route, get ''/users/:city'' => >>>>>>>> ''users#index'', :as => list_users_with_city >>>>>>>> This works fine. I get proper output. >>>>>>> >>>>>>> >>>>>>>> What could be the problem? >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Ruby on Rails: Talk" group. >>>>>>>> To post to this group, send email to >>>>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To view this discussion on the web visit >>>>>>>> https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. >>>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> ------------------------------------------------------------- >>>>>>> visit my blog at http://jimlabs.heroku.com >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Ruby on Rails: Talk" group. >>>>>>> To post to this group, send email to >>>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Ruby on Rails: Talk" group. >>>>>> To post to this group, send email to >>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> ------------------------------------------------------------- >>>>> visit my blog at http://jimlabs.heroku.com >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Ruby on Rails: Talk" group. >>>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Talk" group. >>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> ------------------------------------------------------------- >>> visit my blog at http://jimlabs.heroku.com >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Nov-30 06:54 UTC
Re: Issue with passing parameter to action using link_to
On Fri, Nov 30, 2012 at 2:50 PM, sumit srivastava < sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Verified it. Don''t have puts anywhere else. >ok. sorry but I ran out of ideas. without looking at the logs or the whole code, i won''t be able to help.> > Regards > Sumit Srivastava > > The power of imagination makes us infinite... > > > On 30 November 2012 11:39, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> >> On Fri, Nov 30, 2012 at 1:50 PM, sumit srivastava < >> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> If it were being directed to some other action, then *************** >>> should not have been printed. And when I am trying to access this parameter >>> from the view "index.html.haml", its value is printed exactly what is being >>> passed. >>> >> >> You''re right but you may have the same kind of puts code in other parts >> of your file. We''re just making >> sure that it really is going to the index action. Try to use debugger >> instead of puts when you''re debugging. >> There may be times when you''re rendering the same template from a >> different action which is why >> the value is printed correctly. >> >> >>> >>> Regards >>> Sumit Srivastava >>> >>> The power of imagination makes us infinite... >>> >>> >>> >>> On 30 November 2012 11:12, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>>> >>>> >>>> >>>> On Fri, Nov 30, 2012 at 1:32 PM, sumit srivastava < >>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>> >>>>> On 30 November 2012 10:55, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Fri, Nov 30, 2012 at 1:16 PM, sumit srivastava < >>>>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>> >>>>>>> On 30 November 2012 10:41, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Fri, Nov 30, 2012 at 12:51 PM, Sumit Srivastava < >>>>>>>> sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> I have a controller named Users with index action. >>>>>>>>> >>>>>>>>> def index >>>>>>>>> puts "************* #{params[:city]}" >>>>>>>>> ... >>>>>>>>> ... >>>>>>>>> end >>>>>>>>> >>>>>>>>> From the view, >>>>>>>>> link_to(:city, list_users_with_city_path(:city => city.name)) >>>>>>>>> >>>>>>>> >>>>>>>> You implied below that list_users_with_city_path is not yet defined >>>>>>>> at this point so why is it not giving any errors? where did you >>>>>>>> get list_user_with_city_path if you haven''t defined it in the >>>>>>>> routed yet? >>>>>>>> >>>>>>> >>>>>>> Wrote this by mistake. I use it this way after defining the path. >>>>>>> What doesn''t works is, >>>>>>> >>>>>>> link_to(:city, users(:city => city.name) >>>>>>> And this is not giving any errors but nothing is received in the >>>>>>> index action. >>>>>>> >>>>>> >>>>>> use users_path. I''m not sure why it''s not giving any errors. >>>>>> >>>>> >>>>> Ah! Again I typed wrong. Yes, this is what I used, users_path and >>>>> seems like I also missed the closing bracket for link_to up here. >>>>> Certainly, it gave errors without "path". >>>>> >>>>> So, with the correct syntax, link_to(:city, users_path(:city => >>>>> city.name)), it didn''t work. >>>>> >>>> >>>> i''m not sure why params[:city] isn''t set when you reach that puts >>>> statement. It may be caused by >>>> a number of things. Can you check if it really goes to the index >>>> action, you may have declared >>>> something on your routes that takes precedence over the users >>>> resources? Paste in the log after >>>> you click on the link and you routes file (everything before the >>>> resources :users line). >>>> >>>> >>>>> >>>>> >>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> But when I click on this link, it doesn''t prints out anything for >>>>>>>>> the params. All the "*" are being printed. The url in the browser displays, >>>>>>>>> >>>>>>>>> localhost:3000/users?city=delhi >>>>>>>>> >>>>>>>>> Instead when I create a new route, get ''/users/:city'' => >>>>>>>>> ''users#index'', :as => list_users_with_city >>>>>>>>> This works fine. I get proper output. >>>>>>>> >>>>>>>> >>>>>>>>> What could be the problem? >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> You received this message because you are subscribed to the Google >>>>>>>>> Groups "Ruby on Rails: Talk" group. >>>>>>>>> To post to this group, send email to >>>>>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To unsubscribe from this group, send email to >>>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>>> To view this discussion on the web visit >>>>>>>>> https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ. >>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> ------------------------------------------------------------- >>>>>>>> visit my blog at http://jimlabs.heroku.com >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Ruby on Rails: Talk" group. >>>>>>>> To post to this group, send email to >>>>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Ruby on Rails: Talk" group. >>>>>>> To post to this group, send email to >>>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> ------------------------------------------------------------- >>>>>> visit my blog at http://jimlabs.heroku.com >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Ruby on Rails: Talk" group. >>>>>> To post to this group, send email to >>>>>> rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>> >>>>>> >>>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Ruby on Rails: Talk" group. >>>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> ------------------------------------------------------------- >>>> visit my blog at http://jimlabs.heroku.com >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ruby on Rails: Talk" group. >>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> ------------------------------------------------------------- >> visit my blog at http://jimlabs.heroku.com >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 30 November 2012 06:50, sumit srivastava <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Verified it. Don''t have puts anywhere else.Jim asked you to post the contents of the log (log/development.log) when you click the link. Why have you not done that? Or have I missed that message? Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Nov-30 08:56 UTC
Re: Issue with passing parameter to action using link_to
On 30 November 2012 14:16, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 30 November 2012 06:50, sumit srivastava > <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Verified it. Don''t have puts anywhere else. > > Jim asked you to post the contents of the log (log/development.log) > when you click the link. Why have you not done that? Or have I > missed that message? >I haven''t posted the log yet because the code I posted is an example of what I am using. I can''t post the code as it is proprietary. And so the log contains info that might violate it.> Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Nov-30 09:13 UTC
Re: Issue with passing parameter to action using link_to
On Fri, Nov 30, 2012 at 4:56 PM, sumit srivastava < sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 30 November 2012 14:16, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> On 30 November 2012 06:50, sumit srivastava >> <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Verified it. Don''t have puts anywhere else. >> >> Jim asked you to post the contents of the log (log/development.log) >> when you click the link. Why have you not done that? Or have I >> missed that message? >> > > I haven''t posted the log yet because the code I posted is an example of > what I am using. I can''t post the code as it is proprietary. And so the log > contains info that might violate it. >Create a new rails app and try to replicate the behavior. If you can do that, we might be able to help. If not, consult within your company. Good luck!> > >> Colin >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
sumit srivastava
2012-Nov-30 09:15 UTC
Re: Issue with passing parameter to action using link_to
On 30 November 2012 14:43, Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Fri, Nov 30, 2012 at 4:56 PM, sumit srivastava < > sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On 30 November 2012 14:16, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >>> On 30 November 2012 06:50, sumit srivastava >>> <sumit.theinvincible-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> > Verified it. Don''t have puts anywhere else. >>> >>> Jim asked you to post the contents of the log (log/development.log) >>> when you click the link. Why have you not done that? Or have I >>> missed that message? >>> >> >> I haven''t posted the log yet because the code I posted is an example of >> what I am using. I can''t post the code as it is proprietary. And so the log >> contains info that might violate it. >> > > Create a new rails app and try to replicate the behavior. If you can do > that, we > might be able to help. If not, consult within your company. Good luck! >Thanks for the help. Will give it a try and post accordingly.> > >> >> >>> Colin >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.