On 8 February 2013 11:00, poornima c. <[email protected]> wrote:
> Am getting the following error in ruby on rails:
> ActiveRecord::UnknownAttributeError in AWRequestsController#new unknown
> attribute: a_w_request_id.
>
> I have a form that is tied to two models.
>
> a_w_request.rb:
>
> class AWRequest <ActiveRecord::Base
>     set_primary_key : request_id
>     set_table_name: w_r_details
>     attr_accessible : request_id,
> :requester_contact,:needed_by,:w_a_details_attributes
>
>     has many: w_a_details, :dependent => :destroy
>
>     accepts_nested_attributes for :w_a_details, :allow_destroy => :true
>     :reject_if => proc {|attrs| attrs.all? {|k,v| v.blank? } }
> end
>
> w_a_detail.rb:
>
> Class WADetail < ActiveRecord::Base
>     set_primary_key :w_a_detail_id
>     set_table_name "w_a_details"
>     attr_accessible :description,:request_id,:w_a_detail_id
>     belong_to :a_w_request, :foreign_key "request_id"

That should be belongs_to not belong_to and foreign_key: "request_id"
or :foreign_key => "request_id"

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to