ruby on rails - self_or_other(message) dose not work -


my app working good, message reply not working when try send massage it's give me error "undefined method `self_or_other'". don't know why it's not working.

the exact error come in web page is:


  nomethoderror in conversations#show    showing c:/users/arvind/project/book/app/views/messages/_message.html.erb    line #1 raised:   undefined method `self_or_other' #<#<class:0x667a1f0>:0x4fb6cd8>   trace of template inclusion: app/views/conversations/show.html.erb   rails.root: c:/users/arvind/project/book  application trace | framework trace | full trace    app/views/messages/_message.html.erb:1:in    `_app_views_messages__message_html_erb___30280179_42148572'        app/views/conversations/show.html.erb:16:in  `_app_views_conversations_show_html_erb___631964137_59734080' 

this _message.html.erb this


<li class="<%=  self_or_other(message) %>">  <div class="avatar">  <img src="http://placehold.it/50x50" />   </div>   <div class="chatboxmessagecontext">   <p><%= message.body %></p>    <time datetime="<%= message.created_at %>" title="<%= message.created_at.strftime("%d %b  %y @ %i:%m%p") %>">     <%= message_interlocutor(message).full_name %> • <%= message.created_at.strftime("%h:%m %p") %>      </time>    </div>  </li> 

this conversation show_html.erb


 <div class="chatboxhead">   <div class="chatboxtitle">    <i class="fa fa-comments"></i>    <h1><%= @reciever.full_name %> </h1>   </div>   <div class="chatboxoptions">   <%= link_to "<i class='fa  fa-minus'></i> ".html_safe, "#", class: "togglechatbox", "data-cid" => @conversation.id %> &nbsp;&nbsp;   <%= link_to "<i class='fa  fa-times'></i> ".html_safe, "#", class: "closechat", "data-cid" => @conversation.id %>   </div>    <br clear="all"/>    </div>   <div class="chatboxcontext">    <% if @messages.any? %>   <%= render @messages %>    <% end %> </div>     <div class="chatboxinput">   <%= form_for([@conversation, @message], :remote => true, :html => {id: "conversation_form_#{@conversation.id}"}) |f| %>     <%= f.text_area :body, class: "chatboxtextarea", "data-cid" => @conversation.id %>     <% end %>   </div>   <%= subscribe_to conversation_path(@conversation) %> 

this app/views/message/create.js.erb


  <% publish_to @path %>   <% broadcast "mesaage" %>    var id = "<%= @conversation.id %>";    var chatbox = $("#chatbox_" + id + " .chatboxcontent");    var sender_id = "<%= @message.user.id %>";    var reciever_id = $('meta[name=user-id]').attr("context");    chatbox.append("<%= j render( partial: @message ) %>");   chatbox.scrolltop(chatbox[0].scrollheight);     if (sender_id != reciever_id) {     chatbox.chatwith(id);     chatbox.children().last().removeclass("self").addclass("other");     chatbox.scrolltop(chatbox[0].scrollheight);     chatbox.notify();   }   <% end %>  <% end %> 

this messages_helper.rb


  module messageshelper    def self_or_other(message)    message.user == current_user ? "self" : "other"   end   def message_interlocutor(message)   message.user == message.conversation.sender ? message.conversation.sender : message.conversation.recipient   end end 

thank you!


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -