2014-12-19 69 views
0

此錯誤重點關注用戶帳戶。我正在使用Devise的寶石。該應用在本地運行良好,我推送到Heroku,並且我的用戶註冊頁面失敗。下面是我在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(本地)

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遷移

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

似乎開發和生產環境之間的數據庫模式存在差異。檢查你的遷移和'db/schema.rb'。 – 2014-12-19 09:51:36

+0

我添加了本地模式文件到我的描述 – 2014-12-19 09:54:33

+0

謝謝,我會比較這些文件 – 2014-12-19 09:55:40

回答

0

Heroku上沒有相同的模式數據,因爲我沒有犯,推動DB/development.sqlite3

These files were not staged for commit

相關問題