Я унаследовал проект Rails и попросил его обновить, поэтому я переношу проект Rails 2.2.2 в Rails 3.2.Rails 3 Migration and application.rb
Я прошел несколько учебных уроков по миграции и запустил скрипт обновления рельсов, и он загружается нормально, когда установлен по умолчанию /public/index.html.
Затем я пошел вперед и удалить /public/index.html, так что приложение будет указывать на файл, указанный в routes.rb, а затем я получаю:
LoadError (Expected /var/www/vendor_sandbox/app/controllers/application.rb to define Application):
app/controllers/application_controller.rb:1:in `<top (required)>'
app/controllers/home_controller.rb:1:in `<top (required)>'
Файл, который вызывает ошибку было от исходной базы данных Rails 2.2.2. Я оставил его, потому что в документах по миграции не было указаний, которые я читал, которые упоминали об удалении, но явно что-то не так.
Я нахожу странным, что теперь у меня есть версия Rails 3 из application.rb в/конфигурации и application.rb в/приложение/контроллеры/
Не уверен, что делать с/приложение/контроллеры/приложения .rb.
Вот файлы, упомянутые:
#### /app/controllers/application.rb
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => 'mysecretkey'
# See ActionController::Base for details
# Uncomment this to filter the contents of submitted sensitive data parameters
# from your application log (in this case, all fields with names like "password").
# filter_parameter_logging :password
def authenticate
return true if session[:user_id].to_i > 0
session[:after_login] = params
redirect_to :controller => "login"
return false
end
def authenticate_admin
user = User.find(session[:user_id])
@nav = [{:title => "Home", :action => {:controller => "home"}}]
return true if user and user.is_admin?
redirect_to :controller => "login"
return false
end
def clean_date_for_4D date
return "00/00/00" if !date or date == ""
return date.strftime("%m/%d/%Y") if date.class.to_s == "Date"
return Date.parse(date).strftime("%m/%d/%Y") # assume it's a string
end
def pad text, length=20
while text.length < length do
text = text + " "
end
return text
end
end
#### /config/routes.rb
VendorSandbox::Application.routes.draw do
match '/' => 'home#index'
match '/:controller(/:action(/:id))'
end
#### /config/application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test)))
end
module VendorSandbox
class Application < Rails::Application
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
# Session key
config.session_store(:cookie_store, {:key => '_vendor_sandbox_session', :secret => 'secretkey'
# Time zone
config.time_zone = 'Central Time (US & Canada)' #'UTC' # Had to change this to keep created_at from being 4 hours in advance!
config.active_record.default_timezone = 'Central Time (US & Canada)'
end
end
Да, это был он. благодаря – Slinky