ruby LED
2012-Apr-02 16:43 UTC
active admin saving selection from collection_select and passing to controller
hi i am using active admin for my app i have a partial with a drop down list where the menu and recipe are populated this page is to group the recipe in a menu _menu_recipe.html.erb <%= semantic_form_for [:admin, @menu_recipe] do |f| %> <p> <%= f.collection_select :recipe_id, Recipe.all,:id,:name,:prompt => true%> </p> <p> <%= f.collection_select :menu_id, Menu.all,:id,:name,:prompt => true%> </p> <%= f.buttons :commit %> <%end%> when ever i try to catch the and create or group it, it comes with a Couldn''t find Recipe without an ID error my active admin controller which i override is ActiveAdmin.register MenuRecipe do menu :parent => "Manage Package" form :partial => "menu_recipe" controller do def new new! do |format| @menu_recipe = MenuRecipe.new end end def create create! do |format| recipe = Recipe.find(params[:recipe_id]) menu = Menu.find(params[:menu_id]) @menu_recipe = @menu.add_recipe(menu.id) if @menu_recipe.save redirect_to {admin_menu_recipe_url} end end end end end i cant seems to get the current menu and recipe that i group -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.