Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 语法错误,意外的tIDENTIFIER,应为关键字\u结束对话控制器_Ruby On Rails_Mailboxer - Fatal编程技术网

Ruby on rails 语法错误,意外的tIDENTIFIER,应为关键字\u结束对话控制器

Ruby on rails 语法错误,意外的tIDENTIFIER,应为关键字\u结束对话控制器,ruby-on-rails,mailboxer,Ruby On Rails,Mailboxer,我已经安装了邮箱gem,并且正在配置它。我一直在尝试设置它,但是当我访问/对话时,我得到一个语法错误意外的消息提示,期望关键字\u end 我似乎看不出哪里出了问题,因为对原始代码进行了修改 class ConversationsController < ApplicationController helper_method :mailbox, :conversation def index @conversations ||= current_user.mailbo

我已经安装了邮箱gem,并且正在配置它。我一直在尝试设置它,但是当我访问/对话时,我得到一个语法错误
意外的消息提示,期望关键字\u end

我似乎看不出哪里出了问题,因为对原始代码进行了修改

class ConversationsController < ApplicationController
  helper_method :mailbox, :conversation

  def index
      @conversations ||= current_user.mailbox.inbox.all
    end

    def reply
      current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
      redirect_to conversation
    end

    def trash_folder     
      @trash ||= current_user.mailbox.trash.all  
       end

    def trash  
      conversation.move_to_trash(current_user)  
      redirect_to :conversations 
      end 

      def untrash  
        conversation.untrash(current_user)  
        redirect_to :back
         end

         def empty_trash   current_user.mailbox.trash.each do |conversation|    conversation.receipts_for(current_user).update_all(:deleted => true)
           end
          redirect_to :conversations
         end

   def create
      recipient_emails = conversation_params(:recipients).split(',')
      recipients = User.where(email: recipient_emails).all

      conversation = current_user.
        send_message(recipients, *conversation_params(:body, :subject)).conversation

      redirect_to conversation
    end

    def reply
      current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
      redirect_to conversation
    end

    def trash
      conversation.move_to_trash(current_user)
      redirect_to :conversations
    end

    def untrash
      conversation.untrash(current_user)
      redirect_to :conversations
    end

    private

    def mailbox
     @mailbox ||= current_user.mailbox
    end

    def conversation
     @conversation ||= mailbox.conversations.find(params[:id])
    end

    def conversation_params(*keys)
     fetch_params(:conversation, *keys)
    end

    def message_params(*keys)
     fetch_params(:message, *keys)
    end

    def fetch_params(key, *subkeys)
     params[key].instance_eval do
       case subkeys.size
       when 0 then self
       when 1 then self[subkeys.first]
       else subkeys.map{|k| self[k] }
       end
     end
    end

控制器末端缺少一个额外的
end

如果您先将代码对齐并正确缩进,那就太好了。该错误是因为您有或缺少额外的
结束
或不匹配的结束。我假设在这部分
def empty_trash current_user.mailbox.trash.each do | conversation | conversation.receipts_for(current_user)。update_all(:deleted=>true)end重定向到:conversations end
。发布整个堆栈跟踪将帮助更多。
  resources :users do |user|

 end

 resources :messages do
   member do
     post :new
   end
 end
 resources :conversations do
   member do
     post :reply
     post :trash
     post :untrash
   end
  collection do
     get :trashbin
     post :empty_trash
  end
end