Hello, I’m trying to add something to my database that contains a has_many association like so
schema "shipments" do
field :label, :string
field :target_date_to_be_shipped, :string
field :status, :string
has_many :routes, Route
I have a new form like so
I want to set a link under route where they can go to route/new and it will be associated with this shipment. is that possible?
something like this in the form is what I was thinking
<%= label f, :routes %>
<span><%= link "New Route", to: group_shipment_route_path(@conn, :new, @group, @shipment) %></span>
<%= error_tag f, :routes %>
But is there a way to associate what’s submitted after the link with this shipment?
Isn’t passing in shipment here already doing the association on the URL?
I think you are trying to accomplish what’s been discussed in this posts:
Please take a look a this post also:
I made some changes that makes it easier to handle the association.
Hope this helps.