My model association looks like this
class User < ActiveRecord::Base
has_many :correlations
has_many :roles, :through => :correlations
has_many :skills, :through => :correlations
end
class Skill < ActiveRecord::Base
has_many :correlations
has_many :roles, :through => :correlations
has_many :users, :through => :correlations
end
class Role < ActiveRecord::Base
has_many :correlations
has_many :users, :through => :correlations
has_many :skills, :through => :correlations
end
class Correlation < ActiveRecord::Base
belongs_to :role
belongs_to :skill
belongs_to :user
end
ON update user each time i have two tpuples in db
for e.g
role_id user_id
skill_id
admin_id u_id Null
Null u_id
skill_id
instead of
role_id user_id
skill_id
admin_id u_id
skill_id
#users/controller
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(@user, :notice => 'User was
successfully
updated.’) }
format.xml { head :ok }
else
format.html { render :action => “edit” }
format.xml { render :xml => @user.errors, :status =>
:unprocessable_entity }
end
end
end
Please suggest
Thanks in advance