Error while bulk inserting in Rails - ruby-on-rails

I am trying to do a bulk insert in Rails ActiveRecord from a different MySQL database. My database is Postgres.
Used the following code and the gem bulk_insert:
batch,batch_size = [], 1_000
records.each do |row|
batch << params
if batch.size >= batch_size
TableName.bulk_insert values: batch
batch = []
end
end
But I am getting errors while trying to do so. First 1000 records are inserted fine. After which I get the following:
from /var/lib/gems/2.3.0/gems/activerecord-5.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
from /var/lib/gems/2.3.0/gems/activerecord-5.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
from /var/lib/gems/2.3.0/gems/activerecord-5.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:590:in `block in log'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
from /var/lib/gems/2.3.0/gems/activerecord-5.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
from /var/lib/gems/2.3.0/gems/activerecord-5.0.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
from /var/lib/gems/2.3.0/gems/bulk_insert-1.5.0/lib/bulk_insert/worker.rb:78:in `block in save!'
from /var/lib/gems/2.3.0/gems/bulk_insert-1.5.0/lib/bulk_insert/worker.rb:78:in `tap'
from /var/lib/gems/2.3.0/gems/bulk_insert-1.5.0/lib/bulk_insert/worker.rb:78:in `save!'
from /var/lib/gems/2.3.0/gems/bulk_insert-1.5.0/lib/bulk_insert/worker.rb:40:in `add'
from /var/lib/gems/2.3.0/gems/bulk_insert-1.5.0/lib/bulk_insert/worker.rb:63:in `block in add_all'
from /var/lib/gems/2.3.0/gems/bulk_insert-1.5.0/lib/bulk_insert/worker.rb:63:in `each'
from /var/lib/gems/2.3.0/gems/bulk_insert-1.5.0/lib/bulk_insert/worker.rb:63:in `add_all'
from /var/lib/gems/2.3.0/gems/bulk_insert-1.5.0/lib/bulk_insert.rb:13:in `block in bulk_insert'
from /var/lib/gems/2.3.0/gems/activerecord-5.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
from /var/lib/gems/2.3.0/gems/activerecord-5.0.3/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
... 22 levels...
from /var/lib/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/console_helper.rb:9:in `start'
from /var/lib/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:78:in `console'
from /var/lib/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /var/lib/gems/2.3.0/gems/railties-5.0.3/lib/rails/commands.rb:18:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `block in require'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:259:in `load_dependency'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require'
from /home/user/rails-app/bin/rails:9:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:287:in `load'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:287:in `block in load'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:259:in `load_dependency'
from /var/lib/gems/2.3.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:287:in `load'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
The size of records is around 100,000. What could be the best way to insert these number of records in the Rails Table?
Am I doing something wrong?

I guess you can make use of ActiveRecord import library
Please read this
also this bulk_insert

Related

finding model in rails gives "ArgumentError: no receiver given"

I just change the name of one of my models, it used to be "Course", and now it's "Booking", also I have created two brand new classes called "Course" and "Lesson" that both inherit from "Booking"
I have updated all the has_many in my models from :courses to :bookings, I made sure to rename the file to booking.rb, and renamed the table in the database to bookings.
When I run this in the rails console
Booking.find 1
I get this error
ArgumentError: no receiver given
The 2nd line below is the one causing the error
if filter.arity <= 0
lambda { |target, _| target.instance_exec(&filter) }
else
lambda { |target, _| target.instance_exec(target, &filter) }
end
Here is the stack trace
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:396:in `instance_exec'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:396:in `block in make_lambda'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:207:in `block in halting_and_conditional'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:456:in `block in call'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:456:in `each'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:456:in `call'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/callbacks.rb:750:in `_run_initialize_callbacks'
from ~/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/core.rb:350:in `init_with'
from ~/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/persistence.rb:69:in `instantiate'
from ~/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/querying.rb:50:in `block (2 levels) in find_by_sql'
from ~/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/result.rb:52:in `block in each'
from ~/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/result.rb:52:in `each'
from ~/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/result.rb:52:in `each'
from ~/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/querying.rb:50:in `map'
from ~/.rvm/gems/ruby-2.3.1/gems/activerecord-5.0.0.1/lib/active_record/querying.rb:50:in `block in find_by_sql'
... 14 levels...
from ~/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in `start'
from ~/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in `console'
from ~/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from ~/.rvm/gems/ruby-2.3.1/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from ~/fidka_app/bin/rails:38:in `<top (required)>'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from ~/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from ~/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from ~/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'

Segfault after creating instance of model in console

I have the following model in my Rails application:
class Window < Gosu::Window
def initialize
super( 250, 100, false )
#background_image = Gosu::Image.new( self, 'hello.png' )
end
def draw
#background_image.draw( 0, 0, 1 )
end
def button_down(id)
close
end
end
As you can see, the model is basically a "hello world" for launching a Gosu library window. I got the idea off "Ruby Tips #336 – Turn Rails into a Game Engine". The problem begins when I do the following:
$ rails console
2.2.1 :001> win = Window.new
Immediately after I press enter I get a segmentation fault with the following stack trace:
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application/boot.rb:18:in `<top (required)>'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:125:in `run'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:125:in `loop'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:131:in `block in run'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:156:in `serve'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:156:in `fork'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/application.rb:183:in `block in serve'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/command_wrapper.rb:38:in `call'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/spring-1.4.4/lib/spring/commands/rails.rb:6:in `call'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `block in load'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
/Users/giancarloguerra/Desktop/testgosu/bin/rails:9:in `<top (required)>'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:394:in `start'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:394:in `catch'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:395:in `block in start'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:485:in `eval_input'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `each_top_level_statement'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `catch'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `block in each_top_level_statement'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `loop'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/ruby-lex.rb:245:in `block (2 levels) in each_top_level_statement'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:486:in `block in eval_input'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:623:in `signal_status'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb.rb:489:in `block (2 levels) in eval_input'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/context.rb:379:in `evaluate'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/workspace.rb:86:in `evaluate'
/Users/giancarloguerra/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/irb/workspace.rb:86:in `eval'
(irb):1:in `irb_binding'
(irb):1:in `new'
/Users/giancarloguerra/Desktop/testgosu/app/models/window.rb:5:in `initialize'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/gosu-0.10.4/lib/gosu/swig_patches.rb:19:in `initialize'
/Users/giancarloguerra/.rvm/gems/ruby-2.2.1/gems/gosu-0.10.4/lib/gosu/swig_patches.rb:19:in `initialize'
Along with information on the loaded features from the console. In the end, the console tells me that I may have found a bug and that I should report it.
Here's what I have done about it:
Checked gosu gem is installed. It is.
Debugged my program.
Followed the stack trace for any remote clues.
I'm all out of ideas here. Any suggestions as to what could be happening? I appreciate your help.
It turns out that the 'Spring' gem was causing the issues. After I removed that, the window executed :)

Error with activerecord -3.1.11 Could not find table (ActiveRecord::Statement Invalid)

Before push my app to heroku, I tested my app in production mode, it works perfectly if its in the development mode, but in production mode I'm getting following error activerecord -3.1.11 Could not find table (ActiveRecord::Statement Invalid).
How to fix this error?
I'm sure that table 'pages' exists.
C:\Sites\ecozap>rails s -e production
=> Booting WEBrick
=> Rails 3.1.11 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/connection_ad
apters/sqlite_adapter.rb:450:in `table_structure': Could not find table 'pages' (ActiveRecord::Statement
Invalid)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/
connection_adapters/sqlite_adapter.rb:333:in `columns'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/
connection_adapters/abstract/connection_pool.rb:95:in `block (2 levels) in initialize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/
connection_adapters/abstract/connection_pool.rb:92:in `block in initialize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/base.rb:712:in `yield'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/base.rb:712:in `default'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/base.rb:712:in `columns'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/base.rb:728:in `column_names'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/base.rb:741:in `column_methods_hash'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/base.rb:1118:in `all_attributes_exists?'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/base.rb:892:in `respond_to?'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/named_scope.rb:193:in `valid_scope_name?'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3.1.11/lib/active_record/named_scope.rb:175:in `scope'
from C:/Sites/ecozap/app/models/page.rb:22:in `<class:Page>'
from C:/Sites/ecozap/app/models/page.rb:21:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:225:in `load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:348:in `require_or_load'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:489:in `load_missing_constant'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:181:in `block in const_missing'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:179:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:179:in `const_missing'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/inflector/methods.rb:124:in `block in constantize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/inflector/methods.rb:123:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/inflector/methods.rb:123:in `constantize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.1.11/lib/action_controller/metal/params_wrapper.rb:148:in `_default_wrap_model'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.1.11/lib/action_controller/metal/params_wrapper.rb:167:in `_set_wrapper_defaults'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.1.11/lib/action_controller/metal/params_wrapper.rb:128:in `inherited'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.1.11/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in with'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.1.11/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with'
from C:/Sites/ecozap/app/controllers/pages_controller.rb:1:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:225:in `load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:348:in `require_or_load'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:302:in `depend_on'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:214:in `require_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/engine.rb:417:in `block (2 levels) in eager_load!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/engine.rb:416:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/engine.rb:416:in `block in eager_load!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/engine.rb:414:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/engine.rb:414:in `eager_load!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/application/finisher.rb:51:in `block in <module:Finisher>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/initializable.rb:30:in `instance_exec'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/initializable.rb:30:in `run'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/initializable.rb:55:in `block in run_initializers'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/initializable.rb:54:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/initializable.rb:54:in `run_initializers'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/application.rb:96:in `initialize!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
from C:/Sites/ecozap/config/environment.rb:5:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:640:in `new_constants_in'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:223:in `load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.1.11/lib/active_support/dependencies.rb:240:in `require'
from C:/Sites/ecozap/config.ru:8:in `block in <main>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/builder.rb:51:in`instance_eval'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/builder.rb:51:in`initialize'
from C:/Sites/ecozap/config.ru:in `new'
from C:/Sites/ecozap/config.ru:in `<main>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/builder.rb:40:in`eval'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/builder.rb:40:in`parse_file'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/server.rb:200:in`app'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/commands/server.rb:46:in `app'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/server.rb:304:in`wrapped_app'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.3.10/lib/rack/server.rb:254:in`start'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/commands/server.rb:70:in `start'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/commands.rb:54:in `block in <top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/commands.rb:49:in `tap'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.1.11/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Right, your table exists, but probably only in development database. It doesn't exist in production database, which is different by default.
You should either run
RAILS_ENV=production bundle exec rake db:migrate
to migrate your production database or edit database.yml file to set your production database to be the same as development database.

rake db:schema:load could not find a table

EDIT from normalocity: My answer hasn't been able to solve this problem, so I'm posting a bounty for alternate solutions.
Original question:
I started to work on a Rails project a week ago, changing many times the database schema using migrations. Yesterday I try to create my database (developement environnement, default configuration) from scratch using these commands :
rake db:drop
rake db:create
rake db:schema:load
I got this message when loading the schema using --trace option :
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Could not find table 'galleries'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:439:in `table_structure'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:322:in `columns'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `block (2 levels) in initialize'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `with_connection'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:92:in `block in initialize'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `yield'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `default'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:106:in `block in initialize'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `yield'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `default'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:717:in `columns_hash'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/locking/optimistic.rb:145:in `locking_enabled?'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation.rb:110:in `to_a'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:159:in `all'
/var/lib/gems/1.9.1/gems/activerecord-3.1.3/lib/active_record/base.rb:441:in `all'
/home/fabien/Dropbox/portfolio/app/admin/photos.rb:10:in `block in <top (required)>'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/dsl.rb:13:in `instance_eval'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/dsl.rb:13:in `run_registration_block'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/namespace.rb:171:in `parse_registration_block'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/namespace.rb:50:in `register'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:87:in `register'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin.rb:60:in `register'
/home/fabien/Dropbox/portfolio/app/admin/photos.rb:1:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `block in load'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:132:in `block in load!'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:132:in `each'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:132:in `load!'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/application.rb:155:in `routes'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin.rb:63:in `routes'
/home/fabien/Dropbox/portfolio/config/routes.rb:9:in `block in <top (required)>'
/var/lib/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:258:in `instance_exec'
/var/lib/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:258:in `eval_block'
/var/lib/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/routing/route_set.rb:235:in `draw'
/home/fabien/Dropbox/portfolio/config/routes.rb:1:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `block in load'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:234:in `load'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/routes_reloader.rb:29:in `block in load_paths'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/routes_reloader.rb:29:in `each'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/routes_reloader.rb:29:in `load_paths'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/routes_reloader.rb:13:in `reload!'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:87:in `reload_routes!'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/reloader.rb:34:in `reload!'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/reloader.rb:28:in `block in initialize'
/ var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/file_update_checker.rb:32:in `call'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
/var/lib/gems/1.9.1/gems/activeadmin-0.3.4/lib/active_admin/reloader.rb:45:in `block in attach!'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:404:in `_run_prepare_callbacks'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/lib/gems/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/reloader.rb:46:in `prepare!'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `run_initializers'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:96:in `initialize!'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/fabien/Dropbox/portfolio/config/environment.rb:5:in `<top (required)>'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:83:in `require_environment!'
/var/lib/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:193:in `block (2 levels) in initialize_tasks'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/lib/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'
Tasks: TOP => db:schema:load => environment
As Rails beginner, I have no idea how to solve this issue especially my schema.rb have commands to create th galleries table.
My code is available here: https://github.com/fabienengels/portfolio
You need to modify your /app/admin/photos.rb
# /app/admin/photos.rb
index :as => :grid, :columns => 6 do |photo|
Gallery.all.each do |gallery|
scope gallery.slug.to_sym do |photos|
photos.where(:gallery_id => gallery)
end
end
# link_to(image_tag(photo.file.url(:thumb)), admin_photo_path(photo))
end
you need to put that code inside the index block. I commented out your link tag there. I'll leave it up to you to figure out how to design your grid/block/whatever. just make sure it's in the index scope. Good luck.
So the issue is that when your app loads, it's loading up your activeadmin stuff. That in turn ends up running Gallery.all to know what scopes to setup.
Running a rake task like schema:load still loads the app, so it's still trying to do Gallery.all but you've just dropped/recreated the db so it's quite rightly saying that the table isn't there.
What you'd like to be able to do is tell ActiveAdmin not to bother configuring itself, as you're just running some migrations.
Luckily, there is a global variable $rails_rake_task that is set in those cases. I'd try not running the code in your active_admin initialiser whenever $rails_rake_task is true or if that doesn't work also not doing any activeadmin configuration (e.g. the stuff in app/admin/photos) if $rails_rake_task is true.
I've never used ActiveAdmin before, but from the documentation, but it seems like you can only reference a single model within an ActiveAdmin.register block, or that you simply haven't made the Gallery model visible inside of this file.
So, in app/admin/photos.rb where you have
ActiveAdmin.register Photo do
...
Gallery.all.each do |gallery| # <= this is invalid, because this file
scope gallery.slug.to_sym do |photos| # doesn't know what `Gallery` (and therefore
photos.where(:gallery_id => gallery) # `galleries` table`) is referring to
end
end
....
end
I'm not sure how to do nested ActiveAdmin registrations, or even if you can, but the error message you're getting is telling you that Gallery is not accessible within the scope of this file, and therefore, it's like, "What 'galleries table? We have no 'galleries' table here.".
So, you could try one of these two things to resolve it and see what happens - hopefully this is either the answer, or will lead you to the answer:
At the very top of the app/admin/photos.rb file, add this exact line:
require '../models/gallery'
If that doesn't work, then instead of Gallery.all.each... try
ActiveAdmin.register Gallery do followed by that same block

Rails server stops working after (what I believe) is switching branches

So I'm working on my app and everything is great. All tests pass, app works beautifully. Then, I switch branches without making any changes, switch back, and get this error when I try to run "rails server" again. This has happened a few times now and I have no idea why.
/Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require': no such file to load -- bcrypt_ext (LoadError)
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `block in require'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt.rb:12:in `<top (required)>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `block in require'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/devise-1.4.9/lib/devise/models/database_authenticatable.rb:2:in `<top (required)>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/devise-1.4.9/lib/devise/models.rb:60:in `const_get'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/devise-1.4.9/lib/devise/models.rb:60:in `block (2 levels) in devise'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/devise-1.4.9/lib/devise/models.rb:59:in `each'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/devise-1.4.9/lib/devise/models.rb:59:in `block in devise'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/devise-1.4.9/lib/devise/models.rb:86:in `devise_modules_hook!'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/devise-1.4.9/lib/devise/models.rb:58:in `devise'
from /Users/beatjunkie84/Desktop/ProjectX/app/models/user.rb:16:in `<class:User>'
from /Users/beatjunkie84/Desktop/ProjectX/app/models/user.rb:13:in `<top (required)>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:454:in `load'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:454:in `block in load_file'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:453:in `load_file'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:340:in `require_or_load'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:491:in `load_missing_constant'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:183:in `block in const_missing'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:181:in `each'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:181:in `const_missing'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in `const_missing'
from /Users/beatjunkie84/Desktop/ProjectX/app/admin/users.rb:1:in `<top (required)>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in `load'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in `block in load'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in `load'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activeadmin-0.3.2/lib/active_admin/application.rb:132:in `block in load!'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activeadmin-0.3.2/lib/active_admin/application.rb:132:in `each'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activeadmin-0.3.2/lib/active_admin/application.rb:132:in `load!'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activeadmin-0.3.2/lib/active_admin/application.rb:155:in `routes'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activeadmin-0.3.2/lib/active_admin.rb:63:in `routes'
from /Users/beatjunkie84/Desktop/ProjectX/config/routes.rb:4:in `block in <top (required)>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:233:in `draw'
from /Users/beatjunkie84/Desktop/ProjectX/config/routes.rb:1:in `<top (required)>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in `load'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in `block in load'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:235:in `load'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:127:in `block in reload_routes!'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:127:in `each'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:127:in `reload_routes!'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:120:in `block in routes_reloader'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/file_update_checker.rb:32:in `call'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/railtie.rb:14:in `block (2 levels) in <class:Railtie>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/callbacks.rb:419:in `_run_prepare_callbacks'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/callbacks.rb:40:in `initialize'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:33:in `new'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:33:in `build'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:79:in `block in build'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:79:in `each'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:79:in `inject'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/stack.rb:79:in `build'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:162:in `app'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application/finisher.rb:35:in `block in <module:Finisher>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `run'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `each'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:134:in `initialize!'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:77:in `method_missing'
from /Users/beatjunkie84/Desktop/ProjectX/config/environment.rb:5:in `<top (required)>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `block in require'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
from /Users/beatjunkie84/Desktop/ProjectX/config.ru:3:in `block in <main>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/rack-1.2.4/lib/rack/builder.rb:46:in `instance_eval'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/rack-1.2.4/lib/rack/builder.rb:46:in `initialize'
from /Users/beatjunkie84/Desktop/ProjectX/config.ru:1:in `new'
from /Users/beatjunkie84/Desktop/ProjectX/config.ru:1:in `<main>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/rack-1.2.4/lib/rack/builder.rb:35:in `eval'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/rack-1.2.4/lib/rack/builder.rb:35:in `parse_file'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/rack-1.2.4/lib/rack/server.rb:162:in `app'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/rack-1.2.4/lib/rack/server.rb:253:in `wrapped_app'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/rack-1.2.4/lib/rack/server.rb:204:in `start'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/commands/server.rb:65:in `start'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/commands.rb:30:in `block in <top (required)>'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/commands.rb:27:in `tap'
from /Users/beatjunkie84/Desktop/ProjectX/bundler/ruby/1.9.1/gems/railties-3.0.1/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I think i've fixed this issue at least 4 times without actually knowing what is causing it or what i did to fix it...what is causing this?
Here is what I do to fix this issue:
1) Checkout the oldest commit I have in my current branch (called 'paperclip').
2) Do bundle install (which installs all gems into bundler/ for some reason)
3) Git add . and/or git stash to get rid of the changes I just made to the unnamed branch after checking out
4) Checkout the initial branch again ('paperclip') and run rails server.
5) It works.
I have no idea what is causing this or what fixes it because seemingly i'm not doing anything for either case. Please help!
Not sure why but this worked:
cd [path to your gems folder]/gems/bcrypt-ruby-3.0.1/ext/mri
ruby extconf.rb
make
sudo make install
found here: no such file to load -- bcrypt_ext (via devise)
looks like 'bcrypt_ext' gem is not installed on your server!
Make sure to run bundle install after updating the source code, e.g. switching branches, or pulling new code revisions..

Resources