I'm new to RoR and I'm doing a small application just to get me started.
I have a suppliers page where it lists all the suppliers and inside that I have a link_to the 'new' products page where I can create a new product, I need to send the supplier id through the link_to to the products page and gets stored in a hidden_field_tag value
here's my products page
<%= form_for @product, :url => {:action => "create"} do |f| %>
        <%= f.label :product_name %>
        <%= f.text_field :name %>
        <%= collection_select(:product, :product_category_id, ProductCategory.all, :id, :category,  {prompt: 'Select category'}) %>
        <%= hidden_field_tag(:supplier_id, Supplier.first[:id]) %>
        <%= f.submit "Create a product", class: "btn btn-primary"%>
    <% end %>`
the Supplier.first[:id] is just to try the code
and this is my suppliers page
<% provide(:title, 'All suppliers') %>
<h1>All suppliers</h1>
<ul class="suppliers">
    <% @suppliers.each do |supplier| %>
    <li>
        <%= link_to supplier.name %>
        <%= link_to "Add a product", products_path, :class => "btn btn-primary",:method => "get" %>
        <div>
            <% if supplier.products.any? %>
            <h5>Products (<%= supplier.products.count %>)</h5>
            <ol>
            <% supplier.products.each do |product| %>
                <li><%= product.name %></li>
                <% end %>
            </ol>
            <% end %>
        </div>
    </li>
    <% end %>
</ul>
Any ideas ?
EDIT:
class ProductsController < ApplicationController
    def new
        @product = Product.new
    end
    def create
        @product = Product.new(params[:product])
        if @product.save
            redirect_to "/products"
        else
            render 'new'
        end
    end
EDIT 2: my products model:
class Product < ActiveRecord::Base
  attr_accessible :name, :supplier_id, :product_category_id
  attr_accessor :supplier_id, :product_category_id
  belongs_to :supplier
  belongs_to :product_category
  validates :supplier_id, presence: true
  validates :product_category_id, presence: true
end
and when I run rake routes I get this :
karam@karam-Inspiron-N5010:~/rails-projects/devise$ rake routes
       new_admin_session GET    /admins/sign_in(.:format)      devise/sessions#new
           admin_session POST   /admins/sign_in(.:format)      devise/sessions#create
   destroy_admin_session DELETE /admins/sign_out(.:format)     devise/sessions#destroy
            admin_unlock POST   /admins/unlock(.:format)       devise/unlocks#create
        new_admin_unlock GET    /admins/unlock/new(.:format)   devise/unlocks#new
                         GET    /admins/unlock(.:format)       devise/unlocks#show
        new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
            user_session POST   /users/sign_in(.:format)       devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
           user_password POST   /users/password(.:format)      devise/passwords#create
       new_user_password GET    /users/password/new(.:format)  devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                         PUT    /users/password(.:format)      devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
       user_registration POST   /users(.:format)               devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy
                products POST   /products(.:format)            products#create
             new_product GET    /products/new(.:format)        products#new
                 product GET    /products/:id(.:format)        products#show
           suppliers_new        /suppliers/new(.:format)       suppliers#new
               suppliers        /suppliers(.:format)           suppliers#index
        suppliers_create        /suppliers/create(.:format)    suppliers#create
                                /products(.:format)            products#new
EDIT3 :
My ProductCategory model:
class ProductCategory < ActiveRecord::Base
  attr_accessible :category
  has_many :products
end
this model's controller is empty.
 
    