Search code examples
ruby-on-railscloud-foundryproduction-environment

Rails production mode 'end' error?


I've been trying to get my project on Cloud Foundry for a while now, and eventually narrowed my problem down to this project going into production mode. Of all the errors to get when switching from development mode to production mode, I somehow managed to get an 'unexpected end' error. The culprit is in a controller, seen below:

  companiesController < ApplicationController
  skip_before_filter :require_login
  end
   #def new

There are a load of comments below this section of code, but nothing else. The skip_before_filter refers to a before filter in the application controller, which looks like this:

  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

Just for the sake of completeness, I should also mention that this application also includes multi-tenancy based on subdomains. The subdomains are based on a tenant table in the database. I only say this to clear up any confusion over my code though, but if it somehow helps to shed some light on this problem, then that's great too! I have taken out all references to multi-tenancy and sub-domains for the moment, and simply want to get this project into production mode, so that shouldn't affect it.

The exact error states is your average "unexpected keyword_end, expecting $end' in the companies controller for that single end in the code shown. It doesn't make any sense to me though, I mean it NEEDS to have an end there. Why it would complain is beyond me...

Any help would be greatly appreciated.


Solution

  • Is that really the code for CompaniesController? Do you know that the class should be defined like this instead?

    class CompaniesController < ApplicationController
      skip_before_filter :require_login
    end
    

    Also, if you're doing multitenancy stuff with Rails, you might want to check out my book about doing that: Multitenancy with Rails.