And as a result its not passing validation.
This is my embedded form :
- form_for [@organization, @referral] do |f|
= f.error_messages
= render :partial => 'referral_fields', :locals => { :f => f }
= f.submit "Submit", :class => "button"
#_referral_fields.html.haml
.grid_7
.grid_1{:style => "width: 64px;"}
= f.label :org_name, "Business", :class => "right"
.grid_4
= f.text_field_tag :org_name
.grid_7
.grid_1{:style => "width: 64px;"}
= f.label :name, '', :class => "right"
.grid_4
= f.text_field_tag :name
.grid_7
.grid_1{:style => "width: 64px;"}
= f.label :email, '', :class => "right"
.grid_2.omega{:style => "width: 114px;"}
= f.text_field_tag :email, '', :style => "width: 125px;"
.grid_1.alpha
= f.label :town, '', :class => "right"
.grid_2
= f.text_field_tag :town, '', :style => "width: 100px;"
And when I click submit, SQL definately reads the data I inputted :
Processing ReferralsController#create (for ::1 at 2010-10-18 09:39:07) [POST]
Parameters: {"name"=>"asdfasd", "commit"=>"Submit", "action"=>"create", "authenticity_token"=>"/1bwOqHjojde3p0Py08mCrko8xULE4R+eXUvT6qf1cE=", "controller"=>"referrals", "org_name"=>"asdfasdf", "organization_id"=>"1", "town"=>"asdfasd", "email"=>"asdfasd"}
Not sure what I'm missing. Here is controllers and models :
#referral.rb
belongs_to :organization, :touch => true
validates_presence_of :org_name, :name, :email, :town
#referrals_controller.rb
def new
@referral = Referral.new
respond_to do |format|
format.html { render :layout => 'manage' }
end
end
def create
@referral = Referral.new(params[:referral])
if @referral.valid? && @organization.referrals << @referral
flash[:notice] = "Referrals saved."
redirect_to new_organization_referrals_path(@organization)
else
render :action => :new, :layout => 'manage'
end
end