class User < ActiveRecord::Base
has_many :companies, :through => :positions
has_many :positions
class Company < ActiveRecord::Base
has_many :positions
has_many :users, :through => :positions
class Position < ActiveRecord::Base
belongs_to :company
belongs_to :user
attr_accessible :company_id, :user_id, :regular_user
end
그리고 내 스키마
create_table "positions", :force => true do |t|
t.integer "company_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "regular_user", :default => true
end
내가
Parameters: {"user"=>{"id"=>"", "first_name"=>"some", "last_name"=>"name",
"phone_number"=>"4074615519", "email"=>"[email protected]", "active"=>"true",
"company_ids"=>["186"], "role_ids"=>["2"], "notification_ids"=>["1", "2", "3"]}}
내가으로 실행하고 문제가 positions.regular_user 인이 PARAMS 항상 사실이있는 모델입니다 때를 do
@user.update_attributes(params[:user])
또는
@user = User.new(params[:user])
if @user.save
pprobably 그것 때문에 디폴트는 true ....하지만 난 3
기본 플래그
그 자체는 사용자가 아닌 위치에 있기 때문에 – Trace