Tuesday, January 31, 2012

Getting error "can't activate sqlite3 (~> 1.3.5), already activated sqlite3-1.3.4" when upgrading to Rails 3.2

Upgradation from Rails 3.1 to Rails 3.2 done successfully. When starting server, getting error :

Exiting
/home/ritesh/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:153:in `block in replace_gem': Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (can't activate sqlite3 (~> 1.3.5), already activated sqlite3-1.3.4. Make sure all dependencies are added to Gemfile.) (LoadError)
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:3:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `block in require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:234:in `block in load_dependency'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:639:in `new_constants_in'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:234:in `load_dependency'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:48:in `resolve_hash_connection'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:39:in `resolve_string_connection'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:23:in `spec'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:127:in `establish_connection'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/railtie.rb:76:in `block (2 levels) in <class:Railtie>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.0/lib/active_record/base.rb:709:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-identity-1.0.0/lib/omniauth/identity/models/active_record.rb:6:in `<module:Models>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-identity-1.0.0/lib/omniauth/identity/models/active_record.rb:5:in `<module:Identity>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-identity-1.0.0/lib/omniauth/identity/models/active_record.rb:4:in `<module:OmniAuth>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-identity-1.0.0/lib/omniauth/identity/models/active_record.rb:3:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/app/models/crowd/credential.rb:1:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:469:in `load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:469:in `block in load_file'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:639:in `new_constants_in'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:468:in `load_file'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:353:in `require_or_load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:502:in `load_missing_constant'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:192:in `block in const_missing'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:190:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:190:in `const_missing'
from /home/ritesh/projects/projects/crowd/config/initializers/omniauth.rb:4:in `block in <top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/omniauth-1.0.0/lib/omniauth/builder.rb:7:in `initialize'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:43:in `new'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:43:in `build'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:112:in `block in build'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:112:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:112:in `inject'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/action_dispatch/middleware/stack.rb:112:in `build'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/engine.rb:470:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/application/finisher.rb:32:in `block in <module:Finisher>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `run'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/application.rb:136:in `initialize!'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/environment.rb:5:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:4:in `require'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:4:in `block in <main>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:1:in `new'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:1:in `<main>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:46:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:70:in `start'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in `tap'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/script/rails:6:in `require'
from /home/ritesh/projects/projects/crowd/spec/dummy/script/rails:6:in `<top (required)>'
from script/rails:6:in `load'
from script/rails:6:in `<main>'


To fix the error:

Change the sqlite version in .gemspec from
s.add_development_dependency "sqlite3"
to
s.add_development_dependency "sqlite3" , "~> 1.3.5"

and run 'bundle install'

Getting error 'undefined method `before_dispatch' for class `Rails::Rack::Logger' (NameError) '

Upgradation from Rails 3.1 to Rails 3.2 done successfully. When starting rails server getting following error:

/home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method': undefined method `before_dispatch' for class `Rails::Rack::Logger' (NameError)
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/initializers/quite_assets.rb:6:in `block in <top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/initializers/quite_assets.rb:2:in `class_eval'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/initializers/quite_assets.rb:2:in `<top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:245:in `load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:245:in `block in load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:245:in `load'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/engine.rb:587:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/engine.rb:587:in `block in <class:Engine>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `run'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `each'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/application.rb:136:in `initialize!'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/ritesh/projects/projects/crowd/spec/dummy/config/environment.rb:5:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:4:in `require'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:4:in `block in <main>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:1:in `new'
from /home/ritesh/projects/projects/crowd/spec/dummy/config.ru:1:in `<main>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:46:in `app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:70:in `start'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in `tap'
from /home/ritesh/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in `<top (required)>'
from /home/ritesh/projects/projects/crowd/spec/dummy/script/rails:6:in `require'
from /home/ritesh/projects/projects/crowd/spec/dummy/script/rails:6:in `<top (required)>'
from script/rails:6:in `load'
from script/rails:6:in `<main>'

To fix the error, 

Place the following code in config/initializers/quiet_assets.rb
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
  def call_with_quiet_assets(env)
    previous_level = Rails.logger.level
    Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
    call_without_quiet_assets(env).tap do
      Rails.logger.level = previous_level
    end
  end
  alias_method_chain :call, :quiet_assets
 end


Getting dependency error for 'twitter-bootstrap-rails' when upgrading to rails 3.2

While upgrading to Rails 3.2, done changes in assets like:

gem 'rails', '3.2.0'

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

And run 'bundle update', it gives following error:

Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    twitter-bootstrap-rails (>= 0) ruby depends on
      actionpack (~> 3.1.1) ruby

    rails (= 3.2.0) ruby depends on
      actionpack (3.2.0)

To fix the issue change the code in Gemfile from
gem 'twitter-bootstrap-rails'
to
gem 'twitter-bootstrap-rails', :git => 'http://github.com/seyhunak/twitter-bootstrap-rails.git'

And run 'bundle update'




Update Rails 3.1 to Rails 3.2


In Gemfile, change following versions of assets and rails

gem 'rails', '3.2.0'

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

Run 'bundle update'

Sunday, January 1, 2012

Getting error "File Error: data may have been lost" while using spreadsheet and exporting excel

I am using "Spreadsheet" gem with Rails 2.3.8. Microsoft Office 2007 is installed on my system.
I successfully fitted the code snippets in one of my controller.
I just wrote the code to create Worksheet and pushed one row record in it.
Number of records pushed in that row is around 330.
When I export the spreadsheet/excel, I got following error:



"File Error: data may have been lost"

Clicked on Ok and it created the excel file with the File Type "Microsoft Office Excel 97-2003 Worksheet" with one sheet having 1 row.
When closely analyzed the sheet, I found that Number of maximum columns that can be in that sheet is only 256 and as I was trying to have around 330 columns hence I was getting the error.