Heroku上的未定义方法错误,但不是本地的

时间:2014-12-19 09:50:35

标签: ruby-on-rails heroku devise ruby-on-rails-3.2

此错误主要针对用户帐户。我正在使用Devise gem。该应用程序在本地运行良好,我推送到Heroku,我的用户注册页面失败。这是我在Heroku日志中发现的:

ActionView::Template::Error (undefined method `name' for #<User:0x0000000455e958>):

app/views/devise/registrations/new.html.erb:12:in `block in _app_views_devise_registrations_new_html_erb___4334866443448261327_23317620'

应用程序/视图/设计/注册/ new.html.erb

<div class="panel panel-default">
  <div class="panel-heading">
    <h1>Sign up</h1>
  </div>

  <div class="panel-body">
    <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
      <%= devise_error_messages! %>

      <div class="form-group">
        <%= f.label :name %>
        <%= f.text_field :name, autofocus: true, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= f.label :email %>
        <%= f.email_field :email, autofocus: true, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= f.label :password %>
        <%= f.password_field :password, class: "form-control" %>
      </div>

      <div class="form-group">
        <%= f.submit "Sign up", class: "btn btn-primary" %>
      </div>
    <% end %>
  </div>

  <div class="panel-footer">
    <%= render "devise/shared/links" %>
  </div>
</div>

的Gemfile

source 'https://rubygems.org'

ruby "1.9.3"

gem 'rails', '3.2.8'
gem 'jquery-rails'
gem 'devise'
gem 'simple_form'
gem 'paperclip'
gem 'cocaine'
gem 'acts_as_list'
gem 'annotate', '2.5.0'
gem "bugsnag"
gem 'bootstrap-sass', '~> 2.2.2.0'

group :production do
    gem 'pg'
end

group :development, :test do
    gem 'sqlite3'
end


group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

user.rb

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :name
  # attr_accessible :title, :body
end

application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery
end

schema.rb(LOCAL)

ActiveRecord::Schema.define(:version => 20141219083930) do

  create_table "items", :force => true do |t|
    t.string   "name"
    t.string   "description"
    t.boolean  "completed",   :default => false
    t.integer  "list_id"
    t.datetime "created_at",                     :null => false
    t.datetime "updated_at",                     :null => false
    t.integer  "position"
  end

  add_index "items", ["list_id"], :name => "index_items_on_list_id"

  create_table "lists", :force => true do |t|
    t.string   "name"
    t.string   "description"
    t.datetime "created_at",  :null => false
    t.datetime "updated_at",  :null => false
    t.integer  "position"
  end

  create_table "users", :force => true do |t|
    t.string   "email",                  :default => "", :null => false
    t.string   "encrypted_password",     :default => "", :null => false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          :default => 0
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.datetime "created_at",                             :null => false
    t.datetime "updated_at",                             :null => false
    t.string   "name"
  end

  add_index "users", ["email"], :name => "index_users_on_email", :unique => true
  add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true

end

add_name_to_users migration

class AddNameToUsers < ActiveRecord::Migration
  def change
    add_column :users, :name, :string
  end
end

1 个答案:

答案 0 :(得分:0)

Heroku没有相同的架构数据,因为我没有提交并推送db / development.sqlite3

These files were not staged for commit