In my app I have lots of model: (products belongs_to creator, creators belongs_to compagnie, compagnies belongs_to SEO, SEOs belongs_to user)
in my first Seoscontroller I have that:
def create
@seo = current_user.seos.build(seo_params)
if @seo.save
redirect_to search_path
else
render :new
end
end
(Controller work find!)
In the Compagniescontroller I think (but not work:[ )
def create
seo = Seo.find(params[:seo_id])
@compagnie = seo.compagnies.build(compagnie_params)
if @compagnie.save
redirect_to search_path
else
render :new
end
end
and in my simple_form....
<%= simple_form_for @compagnie(seo_id: seo.id) do |f| %>
<% end %>
I search a solution for associate my model id to the controller and the simple_form_for
(my rails error: RuntimeError at /compagnies/new Association :seo_id not found)
Thanks
Aucun commentaire:
Enregistrer un commentaire