【问题标题】:Rails production mode 'end' error?Rails 生产模式“结束”错误?
【发布时间】:2013-04-17 22:16:41
【问题描述】:

一段时间以来,我一直在尝试将我的项目放在 Cloud Foundry 上,最终将我的问题缩小到该项目进入生产模式。在从开发模式切换到生产模式时出现的所有错误中,我以某种方式设法得到了一个“意外结束”错误。罪魁祸首在控制器中,如下所示:

  companiesController < ApplicationController
  skip_before_filter :require_login
  end
   #def new

在这部分代码下面有很多 cmets,但没有别的。 skip_before_filter 指的是应用控制器中的前置过滤器,如下所示:

  class ApplicationController < ActionController::Base
  protect_from_forgery
  include SessionsHelper    

  before_filter :require_login

 def current_company
   Company.find_by_subdomain! request.subdomain
 end
 helper_method :current_company

 def scope_current_company
   Company.current_id = current_company.id
   yield
 ensure
   Company.current_id = nil
 end

def require_login
  if current_user == nil
    flash[:failure] = "You must log in to access that resource"
     redirect_to signin_path
   end
 end
end

为了完整起见,我还应该提到这个应用程序还包括基于子域的多租户。子域基于数据库中的租户表。我这样说只是为了消除对我的代码的任何困惑,但如果它以某种方式有助于阐明这个问题,那也很棒!目前我已经删除了所有对多租户和子域的引用,只是想让这个项目进入生产模式,所以不应该影响它。

确切的错误状态是您的平均“意外关键字_end,期望公司控制器中显示的代码中的那个单端的 $end”。但这对我来说没有任何意义,我的意思是它需要结束那里。为什么它会抱怨我无法理解......

任何帮助将不胜感激。

【问题讨论】:

    标签: ruby-on-rails cloud-foundry production-environment


    【解决方案1】:

    这真的是CompaniesController 的代码吗?你知道这个类应该这样定义吗?

    class CompaniesController < ApplicationController
      skip_before_filter :require_login
    end
    

    另外,如果您正在使用 Rails 进行多租户操作,您可能需要查看我的相关书籍:Multitenancy with Rails

    【讨论】:

    • 我正要写同样的答案。我想不通的事实是@Marc 控制器的代码如何在开发环境中工作?
    • 我不敢相信我错过了如此明显的东西......我一定是改变了它然后忘记了它。我为此工作了几个小时,几个小时,筋疲力尽!谢谢大家的帮助!
    猜你喜欢
    • 2012-07-21
    • 2011-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-09
    • 2018-09-06
    • 2012-10-05
    相关资源
    最近更新 更多