在运行迁移后运行我的应用程序时出现此错误,其中我删除了一列并添加了 2 个新列。我收到此错误
Internal Server Error can't convert String into Integer
在我的应用程序的每个视图/页面上?我是新来的轨道。需要帮忙。提前致谢。
[2013-11-07 04:26:57] ERROR TypeError: can't convert String into Integer
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/descendants_tracker.rb:22:in `delete'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/descendants_tracker.rb:22:in `block in clear'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/descendants_tracker.rb:20:in `each'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/descendants_tracker.rb:20:in `clear'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.1.1/lib/rails/application/bootstrap.rb:56:in `block (2 levels) in <module:Bootstrap>'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:404:in `_run_cleanup_callbacks'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:51:in `cleanup!'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:62:in `close'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.3.5/lib/rack/body_proxy.rb:14:in `close'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.1.1/lib/rails/rack/content_length.rb:30:in `call'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.1.1/lib/rails/rack/log_tailer.rb:14:in `call'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.3.5/lib/rack/handler/webrick.rb:59:in `service'
/home/faraz/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/faraz/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/faraz/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
[2013-11-07 04:27:04] ERROR TypeError: can't convert String into Integer
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/descendants_tracker.rb:22:in `delete'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/descendants_tracker.rb:22:in `block in clear'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/descendants_tracker.rb:20:in `each'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/descendants_tracker.rb:20:in `clear'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.1.1/lib/rails/application/bootstrap.rb:56:in `block (2 levels) in <module:Bootstrap>'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:404:in `_run_cleanup_callbacks'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:51:in `cleanup!'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:62:in `close'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.3.5/lib/rack/body_proxy.rb:14:in `close'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.1.1/lib/rails/rack/content_length.rb:30:in `call'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.1.1/lib/rails/rack/log_tailer.rb:14:in `call'
/home/faraz/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.3.5/lib/rack/handler/webrick.rb:59:in `service'
/home/faraz/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/faraz/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/faraz/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread
我运行了这个迁移
class AddHashedColumns < ActiveRecord::Migration
def change
remove_column :i_users, :password
add_column :i_users, :hashed_password, :string
add_column :i_users, :salt, :string
end
end
我的模型代码是这个
require 'digest/sha1'
class IUser < ActiveRecord::Base
# a non database attribute
attr_accessor :password
has_one :e_user
has_one :j_user
has_one :s_user
validates_presence_of :first_name
validates_presence_of :last_name
#validates :password, presence: true, :length => { :minimum => 6}
validates_uniqueness_of :email, :message => ": This email is already registered!"
validates_presence_of :email
#validate password only on create, i.e. on update user can update other fields
#without changing password
validates_length_of :password, :within =>6..30, :on => :create
before_save :create_hashed_password
after_save :clear_password
attr_protected :hashed_password, :salt
def self.authenticate(email="", password="")
user = IUser.find_by_email(email)
if user && user.hashed_password==IUser.hash_with_salt(password, user.salt)
return user
else
return false
end
end
def self.make_salt(email="")
Digest::SHA1.hexdigest("Use #{email} with #{Time.now} to make a solid salt!")
end
def self.hash_with_salt(password="", salt="")
Digest::SHA1.hexdigest("Put #{salt} on the #{password}")
end
def self.hash(password="")
Digest::SHA1.hexdigest(password)
end
private
def create_hashed_password
#when password is present, we hash it
unless password.blank?
#make a salt, if not made yet
self.salt = IUser.make_salt(email) if salt.blank?
self.hashed_password = IUser.hash_with_salt(password, salt)
end
end
def clear_password
self.password = nil
end
end
这是我的宝石文件
#---------------------------------GEM FILE ---------------------------------------------
source 'http://rubygems.org'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
ruby '1.9.3'
gem 'mysql2'
# gem 'rails', '3.2.14'
# gem install activerecord-mysql2-adapter
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
gem "hirb"
#gem "will_paginate"
#gem "kaminari"
#gem 'rd_searchlogic', :require => 'searchlogic', :git => 'git://github.com/railsdog/searchlogic.git'
#gem "searchlogic"
#gem "activesupport"
gem "devise"
gem "cancan"
gem "jquery-rails"
#gem "rspec-rails", ">= 2.0.1", :group => [:development, :test]
#gem "capybara", :group => [:development, :test]
gem 'twitter-bootstrap-rails', :git => 'http://github.com/seyhunak/twitter-bootstrap-rails.git'
#------------------------------------------------------------------------------------------------------------------------------------
我试图在 Firefox 和 Chromium 上运行我的应用程序,也清除了 cookie 仍然出现相同的错误。