Aryk Grosz
2006-Dec-21 19:25 UTC
using params[] in view or setting the value in controller?
If i pass a param like params[:bid], should I do something like @bid params[:bid] and then use @bid in the code. Or should I just use params[:bid] in the actual view? -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne
2006-Dec-21 19:52 UTC
Re: using params[] in view or setting the value in controlle
Aryk Grosz wrote:> If i pass a param like params[:bid], should I do something like @bid > params[:bid] and then use @bid in the code. Or should I just use > params[:bid] in the actual view?Using params[:bid] directly is fine, mostly. as long you feel comfortable with using whatever is in the url, not modified at all. Often though, you want to validate or alter that data. In those cases it''s better to assign it to an instance variable so you can be sure it''s the data after alteration and validation, rather than what ever is in the url. -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tom Mornini
2006-Dec-21 22:23 UTC
Re: using params[] in view or setting the value in controller?
I''d highly recommend divorcing the views from the params hash. If you choose to change the param name, why should the view need to be changed? What if you decide that value needs to stored in the session rather than passed as a param, for instance? -- -- Tom Mornini, CTO -- Engine Yard, Ruby on Rails Hosting -- Reliability, Ease of Use, Scalability -- (866) 518-YARD (9273) On Dec 21, 2006, at 11:25 AM, Aryk Grosz wrote:> If i pass a param like params[:bid], should I do something like @bid > params[:bid] and then use @bid in the code. Or should I just use > params[:bid] in the actual view? > > -- > Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Aryk Grosz
2006-Dec-22 19:09 UTC
Re: using params[] in view or setting the value in controlle
Hi Alex, Thanks for the response. The only thing that annoys me is that if i have params[:all], i have to put that in everwhere cuz its kinda long a repetitive, whereas setting @all=params[:all], i could just use @all. Im wondering what other people do on this? -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---