I have problem in my project, i am trying to create chat box. but every time i'm getting same error: undefined local variable or method `user' in my conversation.rb . i don't know were i went wrong.

The error which i receive in my web page is:

---

```
 NameError in ConversationsController#show
 undefined local variable or method `user' for #<Module:0x7351368>

Rails.root: C:/Users/Arvind/project/book
Application Trace | Framework Trace | Full Trace

 app/models/conversation.rb:10:in `block in <class:Conversation>'
 app/models/conversation.rb:9:in `<class:Conversation>'
 app/models/conversation.rb:1:in `<top (required)>'
 app/controllers/conversations_controller.rb:17:in `show'

```

---

My conversation.rb look like this

---

```
 class Conversation < ActiveRecord::Base
 belongs_to :sender, :foreign_key => :sender_id, class_name: 'User'
belongs_to :recipient, :foreign_key => :recipient_id, class_name: 'User'

has_many :messages, dependent: :destroy

validates_uniqueness_of :sender_id, :scope => :recipient_id

 scope :involving, -> {(user)} do
  where("conversations.sender_id =? OR conversations.recipient_id  =?",user.id,user.id)
 end

scope :between, -> {(sender_id  recipient_id)} do
 where("(conversations.sender_id = ? AND conversations.recipient_id =?) OR (conversations.sender_id = ? AND conversations.recipient_id =?)", sender_id,recipient_id, recipient_id, sender_id)
  end 
end

```

---

This is my conversation controller.rb look like this:

---

```
  class ConversationsController < ApplicationController
  before_filter :authenticate_user!

  layout false

 def create
   if Conversation.between(params[:sender_id],params[:recipient_id]).present?
   @conversation =   Conversation.between(params[:sender_id],params[:recipient_id]).first
 else
   @conversation = Conversation.create!(conversation_params)
end

  render json: { conversation_id: @conversation.id }
end

 def show
  @conversations = Conversation.involving(User.first)
  @reciever = interlocutor(@conversation)
  @messages = @conversation.messages
  @message = Message.new
end

 private
   def conversation_params
   params.permit(:sender_id, :recipient_id)
end

def interlocutor(conversation)
   current_user == conversation.recipient ? conversation.sender : conversation.recipient
 end

```

end

---

Thank You!!