I've been slaving at this problem for a day an a half now. I'm using the Mailboxer gem to to create a very cut-and-dried messaging system; one that's identical to the sample - https://github.com/RKushnir/mailboxer-app - just to start off with this gem.
I literally have both repositories sitting next to each other on my computer. The mailboxer-specific models, migrations, initializers, everything I can find. This includes the User model, with the name
action. I've even tried messing around with the Notification
model with the attr_accessible
.
The databases are identical.
When I try in the console/seeds to create a Message after a conversation is saved in the sample app, it's quite easy. Once the conversation is saved I run:
n = Message.new
n.sender = User.find(1)
n.subject = 'Hi'
n.body = 'Hello there.'
n.conversation_id = Conversation.find(1).id
n.save
And boom. It works beautifully. My app, on the other hand, will function identically; until it gets to the sender
field.
When I try to set the sender:
n.sender = User.find(1)
I receive this error: NoMethodError: undefined method 'sender=' for #<Message:0x00000101708eb8>
Why??
This is driving me crazy. I would really be appreciative if someone could lend some assistance. Thank you in advance.
Message/Notification schema :
create_table "notifications", force: true do |t|
t.string "type"
t.text "body"
t.string "subject", default: ""
t.integer "sender_id", null: false
t.integer "conversation_id"
t.boolean "draft", default: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.integer "notified_object_id"
t.string "notified_object_type"
t.string "notification_code"
t.string "attachment"
t.boolean "global", default: false
t.datetime "expires"
end
add_index "notifications", ["conversation_id"], name: "index_notifications_on_conversation_id", using: :btree
This is what the gem generates, and it is identical to the sample app as well.