私は次のエラーです
ActiveRecord::AssociationTypeMismatch in ProposalsController#create
User(#78682120) expected, got String(#68929150)
Rails.root: /home/james/app
Application Trace | Framework Trace | Full Trace
app/controllers/proposals_controller.rb:76:in `new'
app/controllers/proposals_controller.rb:76:in `create'
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"0qTzQ/KMA2Ch60aajSg265tThfCTBCB7w0rS8nD4Qwg=",
"proposal"=>{"phones"=>"",
"broadband"=>"",
"fixed_line"=>"",
"group_calling"=>"",
"frequent_txt"=>"",
"frequent_data"=>"",
"type"=>"TelecommunicationsProposal",
"contact_type"=>"",
"extra_options"=>"",
"current_provider"=>"",
"closing_date"=>"03/12/2012",
"users"=>["#<User:0x961c9e4>"]},
"commit"=>"Create Proposal"}
ユーザーが多くのプロポーザルを持ち、そのプロポーザルが多くのユーザーを持つことができるような関係を築こうとしています。
ユーザーごとに提案をもらえると思いますが、その逆も必要です。
Proposal.rb
class Proposal < ActiveRecord::Base
has_many :users
...
TelcommunicationsProposal.rb
class TelecommunicationsProposal < Proposal
belongs_to :users
after_create :proposal_creation
...
ProposalsController.rbProposal.newの作成である76行目でエラーが発生します
def create
@proposal = Proposal.new(params[:proposal])
if current_user
@user = current_user
app / views / telecommunications_proposal/_form.html.erbからの小さな抜粋
<% for user in User.find(:all) %>
<div>
<%= check_box_tag "proposal[users][]",user%>
<%= user.trading_name %>
</div>
<% end %>
誰かが私がどこで間違っているのか教えてもらえますか?