why is message_id_equals method missing in Rails 3?
I seem to have this error, and I'm not doing anything special:
NameError (undefined method `message_id_equals' for class `ActiveRecord::Relation')
Why?开发者_C百科 Here is the context:
@user_has_message = UserHasMessages.user_id_is(current_user.id).message_id_is(@message.id)
irb(main):012:0> UserHasMessages
=> UserHasMessages(id: integer, user_id: integer, message_id: integer, is_sender: boolean, created_at: datetime, updated_at: datetime)
You can't chain those together like that. You're called user_id_is on UserHasMessages, which returns an ActiveRecord response which doesn't contain a method for message_id_is. I don't really know what these methods are, but my guess is that they aren't scopes or it would allow you to chain like that.
Can't you do:
@user_has_message = UserHasMessages.where(:user_id => current_user.id, :message_id => @message.id)
To get the same effect?
精彩评论