i have a recipe table id recipe_title diet_id meal_id I have set up the associations and can create, edit and delete recipes no problem. I have set up navigation with a list of diets for example low carb, high fibre which when clicked shows all the recipes with that type of diet. I then display a list of meals, breakast, lunch, dinner snack etc. I''m unsure how to do the select in the controller/model so that only breakfast for that diet are shown Can anyone give me some pointers as to how to proceed. regards Martin -- 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 -~----------~----~----~----~------~----~------~--~---
I believe e.g., Recipe.find_by_diet_id_and_meal_id(12, 34) should work. -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Martin Evans Sent: Monday, October 13, 2008 8:01 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Searching on two table fields i have a recipe table id recipe_title diet_id meal_id I have set up the associations and can create, edit and delete recipes no problem. I have set up navigation with a list of diets for example low carb, high fibre which when clicked shows all the recipes with that type of diet. I then display a list of meals, breakast, lunch, dinner snack etc. I''m unsure how to do the select in the controller/model so that only breakfast for that diet are shown Can anyone give me some pointers as to how to proceed. regards Martin -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Roy Pardee wrote:> I believe e.g., Recipe.find_by_diet_id_and_meal_id(12, 34) should work.Thanks but how do I pass the parameters in link_to regards Martin -- 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 -~----------~----~----~----~------~----~------~--~---
link_to "click me" :controller => ''some_controller'', :action => ''my_action'', :this_recipe_id => @recipe, :this_meal_id => @meal But depending on where you put that link there are probably shorthands you can use. HTH, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Martin Evans Sent: Monday, October 13, 2008 9:10 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: Searching on two table fields Roy Pardee wrote:> I believe e.g., Recipe.find_by_diet_id_and_meal_id(12, 34) should work.Thanks but how do I pass the parameters in link_to regards Martin -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Roy Pardee wrote:> link_to "click me" :controller => ''some_controller'', :action => > ''my_action'', :this_recipe_id => @recipe, :this_meal_id => @meal > > But depending on where you put that link there are probably shorthands > you can use. > > HTH, > > -Roythanks Roy, that''s been a great help -- 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 -~----------~----~----~----~------~----~------~--~---