Hi, Say I have a model with the following properties I am trying to create a link with all of the properties of a model as parameters. Is this possible in a generic way? Say I have the model: filter = Filter.new filter.page_number = 2 filter.page_size = 10 filter.query = ''books'' I want to create a link link: <a href="some/action/?page_number=2&page_size=10&query=books"> Thanks, GiantCranes -- 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 -~----------~----~----~----~------~----~------~--~---
Hi, I am trying to create a link with all of the properties of a model as parameters. Is this possible in a generic way? Say I have the model: filter = Filter.new filter.page_number = 2 filter.page_size = 10 filter.query = ''books'' I want to create a link link: <a href="some/action/?page_number=2&page_size=10&query=books"> Thanks, GiantCranes -- 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 -~----------~----~----~----~------~----~------~--~---
Sorry for the double post, please ignore this one and use: http://www.ruby-forum.com/topic/93453 -- 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 -~----------~----~----~----~------~----~------~--~---
> @filter = Filter.new > @filter.page_number = 2 > @filter.page_size = 10 > @filter.query = ''books''-- untested code. the idea is that @filter.attributes returns a hash like @filter.attributes = {:page_number => 2, :page_size => 10, :query => ''books''} so, you should aim for something like: link_to "abc", {:controller => ''some'', :action => ''action'', @filter.attributes } **((you may need to do some hash - manipulation, so you don''t get a hash in a hash (you want it all to be in one hash), but that''s the idea... hth, shai -- 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 -~----------~----~----~----~------~----~------~--~---
hash manipulation could go for : Hash#update http://rubycentral.com/book/ref_c_hash.html#Hash.update something like: n={:a => 1, :b => 2 } m={:c => 3} n.update(m) # gives {:a => 1, :b => 2, :c => 3} this way you can add the two hashes of {:controller => x,:action => y} and {:page_number =>2, :other => attributes} :) ciao s -- 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 -~----------~----~----~----~------~----~------~--~---