0

I am getting this error when i run my app after running a migration in which i dropped a column and added 2 new columns. I am getting this error

    Internal Server Error can't convert String into Integer 

on every view/page of my app? I am new to rails. Need help. Thanks in advance.

    [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

I ran this migration

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

and my model code is this

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

This is my gemfile

    #---------------------------------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'

#------------------------------------------------------------------------------------------------------------------------------------

I have tried to run my app on Firefox and Chromium, also cleared cookies still same error is appearing on both.

  • show us the previous and current, fields and types. – Nithin Nov 07 '13 at 09:40
  • Added code of migration file and model. I only change model to implement authentication with hashing. Other files are all same as previously working app. –  Nov 07 '13 at 09:48
  • Check out the log. It should contain the file where the error occurred and on which line number. – Sachin Prasad Nov 07 '13 at 10:31
  • There is no line no. in log file which i could find. –  Nov 07 '13 at 10:44
  • Please post your gemfile. Did you change any gems? I think the problem is with 'bootstrap-sass' gem – Charizard_ Nov 07 '13 at 10:59
  • I have posted gemfile, and i did not change any gems. –  Nov 07 '13 at 12:32
  • Looks like something is wrong within the request itself. Did you try cleaning the browser cache or using a different browser? Is it reproducible? – phoet Nov 07 '13 at 13:30
  • I have tried it on Firefox and Chromium, also tried after clearing cookies still same error is appearing on both. –  Nov 07 '13 at 13:37

1 Answers1

0

I solved the error using the old version of project and using the db with above given migrations applied on it. Then i started entering the new code of model in my project, and ran the project, the error was gone! Thanks