Rails relationship does not exist

Rails 4.1 application. I can get around this, but wonder why it doesn't work:

class NotificationSettings < ActiveRecord::Base belongs_to :user end class User < ActiveRecord::Base has_one :notification_settings end 

This does not work:

 # test/fixtures/notification_settings.yml wilmas_notification_settings: user: wilma checkin_comments: false checkin_comments_schedule: instant 

This job:

 # test/fixtures/notification_settings.yml wilmas_notification_settings: user_id: wilma checkin_comments: false checkin_comments_schedule: instant 

Everything indicates that this is a problem with belongs_to , but I'm puzzled.

Error:

 ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "user" of relation "notification_settings" does not exist LINE 1: INSERT INTO "notification_settings" ("user", "checkin_commen... ^ : INSERT INTO "notification_settings" ("user", "checkin_comments", "checkin_comments_schedule") VALUES (550831404, 'f', 'instant') 
+6
source share
1 answer

It turns out the pluralization of notification_settings discards it. This fixed this:

 ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.uncountable %w(notification_settings) end 
+4
source

All Articles