Record id 116 doesn’t exist so it should return nil to @conversation.
I tried to make it redirect when it gets nil, but it still shows the error when I access example.com/messages/show?id=116 .
The error is
undefined method `is_participant?’ for nil:NilClass
I definitely see ‘is_participant’ method existing in
/usr/local/lib/ruby/gems/1.9.1/gems/mailboxer-0.7.0/app/models/conversation.rb
messages_controller.rb
def show
@conversation = Conversation.find_by_id(params[:id])
unless @conversation.is_participant?(current_user)
flash[:alert] = "You do not have permission to view that conversation."
redirect_to :controller => 'messages', :action => 'received'
end
@messages = Message.find_by_id(params[:id])
current_user.read(@conversation)
end
You need to check that
@conversationis not nil before you call a method on it. Try