ruby on rails - Unknown attributes account id -


i have devise model named "account", , i'm trying create friendships between users using friendship model has initiator user id , friend user id.
have view list of users current user can add, , when press add button, friendship should created:

 <td><%= link_to "add friend", friendships_path(:friend_id => account.id), :method => :post %></td> 

i'm having following error: unknown attribute: account_id

 def create     @friendship = current_account.friendships.build(:friend_id => params[:friend_id])     if @friendship.save       flash[:notice] = "added friend."       redirect_to root_url     else       flash[:error] = "unable add friend."       redirect_to root_url     end   end  class friendship < activerecord::base    belongs_to :account   belongs_to :friend, :class_name => "account" end 

if, said, friendship schema has user_id , friend_id, error:

unknown attribute: account_id 

is normal. rename user_id account_id in schema , should works.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -