Ben Fulton
Ben Fulton

Reputation: 3998

ActiveRecord foreign keys not being saved

I'm trying to save a simple object with keys into two other existing objects. Here's the object:

class Tag < ActiveRecord::Base
  belongs_to :User, :autosave => true
  belongs_to :Comment, :autosave => true
end

I thought creating one of these would be as simple as

@uls = Tag.create(:Comment => @comment, :User => current_user )
@uls.save

This saves the tag correctly, but the user_id and comment_id fields are never set, they're always null. What is the correct command to get the foreign keys to save?

Upvotes: 0

Views: 154

Answers (1)

clyfe
clyfe

Reputation: 23770

lowercase belongs_to :user, same for comment

Upvotes: 2

Related Questions