Let us say, I have a page with couple of links and i would like to send unique flag/variable settings through params for each these links when they are clicked. For example: A link clicked - flag ''a'' sent B link clicked - flag ''b'' sent The exact scenario is that when the link is clicked, I have to perform a "find" to see if the params value exists in table 1 or 2 or 3...so on. This is a very bad design and it is costly in terms of performance. If I can set a flag/variable/indicator with each link, then I can straight away perform "find" in its corresponding table and execute the query. Any pointers are more appreciated. -- Posted via http://www.ruby-forum.com/.
On Jul 21, 5:24 am, Rails List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Let us say, I have a page with couple of links and i would like to send > unique flag/variable settings through params for each these links when > they are clicked. > > For example: > > A link clicked - flag ''a'' sent > B link clicked - flag ''b'' sent > > The exact scenario is that when the link is clicked, I have to perform a > "find" to see if the params value exists in table 1 or 2 or 3...so on. > > This is a very bad design and it is costly in terms of performance. >When you generate a link you either pass a hash of routing options (eg :controller => ''foo'', :action => ''...'') or you call one of the named route helpers (person_path(...)) which can also take similar options. You can add any options you want (although the rails way these days would probably to make the table in question explicit in the url path itself rather than as a query parameter) Fred> If I can set a flag/variable/indicator with each link, then I can > straight away perform "find" in its corresponding table and execute the > query. > > Any pointers are more appreciated. > -- > Posted viahttp://www.ruby-forum.com/.
you can always add extra parameter in link_to or link_to_remote .. every method will allow you to send extra parameter to the controller in all cases whether you are using restful routing or not for example: link_to "a" ,{:controller=>:your_controller, :method => :your_method , :flag=>"a"} or link_to "a" , you_controller_path(:flag=>"a") On Jul 21, 10:24 am, Rails List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Let us say, I have a page with couple of links and i would like to send > unique flag/variable settings through params for each these links when > they are clicked. > > For example: > > A link clicked - flag ''a'' sent > B link clicked - flag ''b'' sent > > The exact scenario is that when the link is clicked, I have to perform a > "find" to see if the params value exists in table 1 or 2 or 3...so on. > > This is a very bad design and it is costly in terms of performance. > > If I can set a flag/variable/indicator with each link, then I can > straight away perform "find" in its corresponding table and execute the > query. > > Any pointers are more appreciated. > -- > Posted viahttp://www.ruby-forum.com/.