Manager :has_many :interns, :through => :assigns
Intern :has_many :managers, :through => :assigns
I am trying to create a new assign record. This is the assigns/new view where a given authenticated intern is creating a new association with a manager:
# assigns/new.html.erb
<% form_for @assign, :url => {:action => "create"} do |p| %>
<%= p.label "Select Manager", nil, :class => "label" %>
<%= collection_select :assign, :manager_id, @managers, :id, :manager_name, options ={:prompt => "Select a manager"}, html_options ={:class =>"listBox", :style => "width:25em;"} %>
<%= p.hidden_field :intern_id %>
<% end %>
# assigns controller
def new
@intern = Intern.find(params[:id])
@assign = Assign.new(:intern_id => @intern.id)
render :layout => 'centered'
end
def create
@assign = Assign.new(params[:assign])
@assign.manager_id = params[:manager_id]
if @assign.save
redirect_to :controller => "interns", :action => "home"
else
render :action => :new
end
end
Problem is: manager_id = nil. Why? Thanks very much.