w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Passing value from one model to another using a drop-down menu

You can do as shown below,

If your path(url) should be like http://loaclhost:3000/category/1/produts, use id params from your url

Pass cateogry id into product view form.erb

<%= f.hidden_field :cat_id , :value => <pass catogory
id from routes url> %>

then follow usual create method ( Please inspect object whether cat_id created or not )

Now , you can access category value from cat_id of product.

Hope it will be useful.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.