I''m a little embarrassed to ask this but I have a url that is like: foo/bar/5?start=45 and in foo_controller I''m trying to access it like so: def bar @start_time = get_start_time(params) end def get_start_time(params) if params[''start''].to_s != nil return ''?start=''+params[''start''].to_s end end I''m coming from PHP/.NET so RESTfulness is a little difficult for me to wrap my head around. Maybe I''m googling on the wrong terms but I haven''t had any luck yet...Any advice would be very appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''m not sure what exactly your trying to do with the get_start_time method when it looks like you just want: @start_time = params[:start] On Mar 4, 3:59 pm, "joshuajnoble" <joshuajno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m a little embarrassed to ask this but I have a url that is like: > > foo/bar/5?start=45 > > and in foo_controller I''m trying to access it like so: > > def bar > @start_time = get_start_time(params) > end > > def get_start_time(params) > if params[''start''].to_s != nil > return ''?start=''+params[''start''].to_s > end > end > > I''m coming from PHP/.NET so RESTfulness is a little difficult for me > to wrap my head around. Maybe I''m googling on the wrong terms but I > haven''t had any luck yet...Any advice would be very appreciated.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here is a good REST pdf. http://www.rubyinside.com/restful-rails-development-pdf-released-392.html --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi thanks for the respone. I just need to have @start_time = "? start="+params[:start] only if params[:start] isn''t empty, i.e. if the url isn''t foo/bar/5?start=45 but is foo/bar/5 On Mar 4, 1:24 am, "flu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <flu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m not sure what exactly your trying to do with the get_start_time > method when it looks like you just want: > > @start_time = params[:start] > > On Mar 4, 3:59 pm, "joshuajnoble" <joshuajno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m a little embarrassed to ask this but I have a url that is like: > > > foo/bar/5?start=45 > > > and in foo_controller I''m trying to access it like so: > > > def bar > > @start_time = get_start_time(params) > > end > > > def get_start_time(params) > > if params[''start''].to_s != nil > > return ''?start=''+params[''start''].to_s > > end > > end > > > I''m coming from PHP/.NET so RESTfulness is a little difficult for me > > to wrap my head around. Maybe I''m googling on the wrong terms but I > > haven''t had any luck yet...Any advice would be very appreciated.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
joshuajnoble wrote:> Hi thanks for the respone. I just need to have @start_time = "? > start="+params[:start] only if params[:start] isn''t empty, i.e. if the > url isn''t > > foo/bar/5?start=45 > > but is > > foo/bar/5def get_start_time(params) if !params[''start''].nil? "?start=#{params[''start'']}" end end or maybe just def get_start_time(params) if params[''start''] "?start=#{params[''start'']}" end end let me know if it works :) -- 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 -~----------~----~----~----~------~----~------~--~---
That works perfectly, thank you so much. I''m curious how ruby, like, well anything else I work with, doesn''t require a return statement: def get_start_time(params) if params[''start''] return "?start=#{params[''start'']}" end end On Mar 4, 10:48 am, mix <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> joshuajnoble wrote: > > Hi thanks for the respone. I just need to have @start_time = "? > > start="+params[:start] only if params[:start] isn''t empty, i.e. if the > > url isn''t > > > foo/bar/5?start=45 > > > but is > > > foo/bar/5 > > def get_start_time(params) > if !params[''start''].nil? > "?start=#{params[''start'']}" > end > end > > or maybe just > > def get_start_time(params) > if params[''start''] > "?start=#{params[''start'']}" > end > end > > let me know if it works :) > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
The value returned by a Ruby method is the value of the last expression evaluated. Read: http://www.rubycentral.com/book/intro.html Best, Thomas Am 04.03.2007 um 17:44 schrieb joshuajnoble:> > > That works perfectly, thank you so much. I''m curious how ruby, like, > well anything else I work with, doesn''t require a return statement: > > def get_start_time(params) > if params[''start''] > return "?start=#{params[''start'']}" > end > end > > > > On Mar 4, 10:48 am, mix <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> joshuajnoble wrote: >>> Hi thanks for the respone. I just need to have @start_time = "? >>> start="+params[:start] only if params[:start] isn''t empty, i.e. >>> if the >>> url isn''t >> >>> foo/bar/5?start=45 >> >>> but is >> >>> foo/bar/5 >> >> def get_start_time(params) >> if !params[''start''].nil? >> "?start=#{params[''start'']}" >> end >> end >> >> or maybe just >> >> def get_start_time(params) >> if params[''start''] >> "?start=#{params[''start'']}" >> end >> end >> >> let me know if it works :) >> >> -- >> Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---