2013-04-08 1 views
2

Я создаю приложение, используя Ruby On Rails и Devise. Я создал модель User и модель администратора, и у меня есть приложение, работающее нормально, когда я запускаю его локально, но когда я запускаю его на heroku, у меня возникают проблемы. Проблема в том, что когда я пытаюсь создать нового администратора, мне показывают сообщение об ошибке «Мы сожалеем, но что-то пошло не так». Я уже сделал rake db: migrate и heroku run rake db: migrate. Когда я проверяю журналы Heroku Я вижу это:Devise Admin работает локально, но не на Heroku

2013-04-08T19:34:49+00:00 app[web.1]: Started GET "/admins/sign_up" for 98.154.183.5 at 2013-04-08 19:34:49 +0000 
2013-04-08T19:34:49+00:00 app[web.1]: Processing by Admins::RegistrationsController#new as HTML 
2013-04-08T19:34:50+00:00 app[web.1]: Rendered devise/registrations/new.html.erb within layouts/application (431.3ms) 
2013-04-08T19:34:50+00:00 app[web.1]: ActionView::Template::Error (undefined method `name' for #<Admin:0x00000005207678>): 
2013-04-08T19:34:50+00:00 app[web.1]: Completed 500 Internal Server Error in 549ms 
2013-04-08T19:34:50+00:00 app[web.1]: 
2013-04-08T19:34:50+00:00 app[web.1]:  3: <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { class: 'form-horizontal'}) do |f| %> 
2013-04-08T19:34:50+00:00 app[web.1]:  4:  <%= f.error_notification %> 
2013-04-08T19:34:50+00:00 app[web.1]:  5: 
2013-04-08T19:34:50+00:00 app[web.1]:  6:  <%= f.input :name %> 
2013-04-08T19:34:50+00:00 app[web.1]:  8:  <%= f.input :password %> 
2013-04-08T19:34:50+00:00 app[web.1]: app/views/devise/registrations/new.html.erb:6:in `block in _app_views_devise_registrations_new_html_erb___3397140481100313441_30072880' 
2013-04-08T19:34:50+00:00 app[web.1]: app/views/devise/registrations/new.html.erb:3:in `_app_views_devise_registrations_new_html_erb___3397140481100313441_30072880' 
2013-04-08T19:34:50+00:00 app[web.1]:  7:  <%= f.input :email %> 
2013-04-08T19:34:50+00:00 app[web.1]:  9:  <%= f.input :password_confirmation %> 
2013-04-08T19:34:50+00:00 app[web.1]: 
2013-04-08T19:34:50+00:00 app[web.1]: 
2013-04-08T19:34:50+00:00 heroku[router]: at=info method=GET path=/admins/sign_up host=protected-cliffs-2228.herokuapp.com fwd="98.154.183.5" dyno=web.1 connect=1ms service=559ms status=500 bytes=643 

По какой-то неизвестной причине мне Heroku не ссылки на администратор/регистрацию/new.html.erb, но вместо этого он ссылки разработать/регистрации/new.html.erb где он читает атрибут 'name', который отображается как неопределенная ошибка метода.

Мои контроллеры/админов/файл registrations_controller.rb выглядит следующим образом:

class Admins::RegistrationsController < Devise::RegistrationsController 

end 

Мой routes.rb файл выглядит следующим образом:

MyFirstApp::Application.routes.draw do 
    get "users/show" 

    devise_for :admins, :controllers => { :registrations => "admins/registrations", :sessions => "admins/sessions" } do 
    get "/admins/sign_up" => "admins/registrations#new" 
    get "/admins/sign_in" => "admins/sessions#new" 
    end 

    resources :posts 


    devise_for :users 
    match 'users/:id' => 'users#show' 


    root :to => 'pages#home' 
    get 'about' => 'pages#about' 

end 

Мой development.rb файл

MyFirstApp::Application.configure do 
    # Settings specified here will take precedence over those in config/application.rb 

    # In the development environment your application's code is reloaded on 
    # every request. This slows down response time but is perfect for development 
    # since you don't have to restart the web server when you make code changes. 
    config.cache_classes = false 

    # Log error messages when you accidentally call methods on nil. 
    config.whiny_nils = true 

    # Show full error reports and disable caching 
    config.consider_all_requests_local  = true 
    config.action_controller.perform_caching = false 

    # Don't care if the mailer can't send 
    config.action_mailer.raise_delivery_errors = false 

    # Print deprecation notices to the Rails logger 
    config.active_support.deprecation = :log 

    # Only use best-standards-support built into browsers 
    config.action_dispatch.best_standards_support = :builtin 

    # Raise exception on mass assignment protection for Active Record models 
    config.active_record.mass_assignment_sanitizer = :strict 

    # Log the query plan for queries taking more than this (works 
    # with SQLite, MySQL, and PostgreSQL) 
    config.active_record.auto_explain_threshold_in_seconds = 0.5 

    # Do not compress assets 
    config.assets.compress = false 

    # Expands the lines which load the assets 
    config.assets.debug = true 

    config.action_mailer.default_url_options = { :host => 'localhost:3000' } 
end 

My production.rb file

MyFirstApp::Application.configure do 
    # Settings specified here will take precedence over those in config/application.rb 

    # Code is not reloaded between requests 
    config.cache_classes = true 

    # Full error reports are disabled and caching is turned on 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 

    # Disable Rails's static asset server (Apache or nginx will already do this) 
    config.serve_static_assets = false 

    # Compress JavaScripts and CSS 
    config.assets.compress = true 

    # Don't fallback to assets pipeline if a precompiled asset is missed 
    config.assets.compile = false 

    # Generate digests for assets URLs 
    config.assets.digest = true 

    # Defaults to nil and saved in location specified by config.assets.prefix 
    # config.assets.manifest = YOUR_PATH 

    # Specifies the header that your server uses for sending files 
    # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 
    # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 

    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 
    # config.force_ssl = true 

    # See everything in the log (default is :info) 
    # config.log_level = :debug 

    # Prepend all log lines with the following tags 
    # config.log_tags = [ :subdomain, :uuid ] 

    # Use a different logger for distributed setups 
    # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 

    # Use a different cache store in production 
    # config.cache_store = :mem_cache_store 

    # Enable serving of images, stylesheets, and JavaScripts from an asset server 
    # config.action_controller.asset_host = "http://assets.example.com" 

    # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) 
    # config.assets.precompile += %w(search.js) 

    # Disable delivery errors, bad email addresses will be ignored 
    # config.action_mailer.raise_delivery_errors = false 

    # Enable threaded mode 
    # config.threadsafe! 

    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 
    # the I18n.default_locale when a translation can not be found) 
    config.i18n.fallbacks = true 

    # Send deprecation notices to registered listeners 
    config.active_support.deprecation = :notify 

    # Log the query plan for queries taking more than this (works 
    # with SQLite, MySQL, and PostgreSQL) 
    # config.active_record.auto_explain_threshold_in_seconds = 0.5 

    #In production, :host should be set to the actual host of your application. 
    config.action_mailer.default_url_options = { :host => 'myfirstapp.heroku.com' } 

    #Configuring Amazon S3 for Paperclip file uploads 
    config.paperclip_defaults = { 
    :storage => :s3, 
    :s3_credentials => { 
     :bucket => ENV['AWS_BUCKET'], 
     :access_key_id => ENV['AWS_ACCESS_KEY_ID'], 
     :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] 
    } 
    } 
end 

Мой .gitignore файл

# See http://help.github.com/ignore-files/ for more about ignoring files. 
# 
# If you find yourself ignoring temporary files generated by your text editor 
# or operating system, you probably want to add a global ignore instead: 
# git config --global core.excludesfile ~/.gitignore_global 

# Ignore bundler config 
/.bundle 

# Ignore the default SQLite database. 
/db/*.sqlite3 

# Ignore all logfiles and tempfiles. 
/log/*.log 
/tmp 
doc/ 
*.swp 
*~ 
.project 
.DS_Store 
.idea 

# Ignore Paperclip unloaded files 
/public/system 

Я бы признателен за любую помощь я могу получить! Это мой первый раз, когда я создаю приложение, поэтому прошу прощения, если мой вопрос немой, но я застрял, и мне нужна помощь!

+0

Два вопроса: 1) вы уверены, что локальная установка действительно отображает представление 'admins/registrations/new.html.erb', а не' devise/registrations/new.html.erb'? и 2) кажется, что вы подклассифицируете Devise :: RegistrationsController и ничего не добавляете к своему собственному контроллеру (у вас нет методов), вы уверены, что вам нужно подклассировать его? –

ответ

0

Сначала проверьте свой gitrepo, чтобы убедиться, что файл или связанный с ним файл по какой-то причине были проигнорированы.

И если это не проблема, тогда просто начните проект героику и начните сначала.

Heroku имеет особый способ иногда не создавать новые репозитории/проекты правильно. Коэффициент неудачи довольно мал, но вы могли бы просто закатить змеиные глаза.

Если это не сработает, опубликуйте свои production.rb и development.rb.

+0

Я не уверен, что вы имеете в виду в этой первой части. Как проверить, чтобы файл или связанный с ним файл были проигнорированы? Прости, что я очень новичок в этом. – ERO310

+0

Если вы используете Mac OSX и загружаете GitX. Существует ряд графических интерфейсов для Git для Windows и Ubuntu. Используйте один из них, чтобы убедиться, что файлы, которые вы хотите отобразить, находятся на самом деле git repo. Другими словами, глядя на репо с Gitx, если вы не видите некоторые файлы, вам нужно будет сделать «git add». Затем повторите попытку. Если это не работает, убедитесь, что ваш файл .gitignore не исключает их по какой-либо причине. – rovermicrover

+0

Все файлы находятся в моем репозитории git. Мой файл .gitignore также не исключает их. Я обновил свой вопрос, чтобы показать свои файлы production.rb и development.rb. Я попытаюсь начать новый проект геройки, как вы предлагали. Спасибо за помощь. – ERO310

 Смежные вопросы

  • Нет связанных вопросов^_^