i am stuck!
i have a products controller, model and list view.
model states: has_many :versions
db table: id, title
i have a versions controller, model and list view.
model states: belongs_to :products
db table: id, num, product_id (hopefully the foreign key!)
i want to know how, in this scenario…
a user selects a product, say microsoft excel -> versions list for excel
are displayed. IVE GOT THIS WORKING!
the passed url is: http://localhost:3000/product/show/1
supposing i want to add a new version for excel, say program id => ‘1’,
how do i do this?
on the view, i have a button “add new version”
this in turn calls a create method in the controller, but i am unsure
how i can pass the product_id across to populate the foreign key in the
versions table. how can i get the product number, when it is only know
from the URL, when passed to enter the associated versions page?
from the view:
Add new version<%= start_form_tag :action => 'create' %>
Number: <%= text_field 'version', 'number' %><%= submit_tag "Create" %> <%= end_form_tag %>
from the version controller:
create a new version
@version = Version.new(params[:version])
redirect_to :controller => ‘product’, :action => ‘show’, :id =>
can you help? do u need more info?
i cant find any similar tutorials on this kind of association! i bought
the agile dev book, no real use!
can you recommened any good sites i could try? or books?