state_machine draw throws uninitialized constant error - ruby-on-rails

On a Rails 3.2 application
Gemfile:
gem "state_machine", "~> 1.1.2"
gem 'ruby-graphviz', :require => 'graphviz'
I installed and use with success the state_machine gem, only when I try to draw the state graph
rake state_machine:draw CLASS=Entity
it throws me this error:
** Invoke state_machine:draw (first_time)
** Execute state_machine:draw
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant StateMachine::Machine::Constants
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:1898:in `draw'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:481:in `block (2 levels) in draw'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:480:in `each_value'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:480:in `block in draw'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:472:in `each'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/state_machine/machine.rb:472:in `draw'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/gems/state_machine-1.1.2/lib/tasks/state_machine.rb:27:in `block (2 levels) in <top (required)>'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/joel/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/bin/rake:19:in `load'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#global/bin/rake:19:in `<main>'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/bin/ruby_noexec_wrapper:14:in `eval'
/Users/joel/.rvm/gems/ruby-1.9.2-p290#biowatts/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => state_machine:draw
Any leads on how to troubleshoot this one?

Dirty but works:
unless defined? StateMachine::Machine::Constants::RGV_VERSION
warn "StateMachine::Machine::Constants overriden in #{__FILE__}"
class StateMachine::Machine::Constants
RGV_VERSION = /^[ ]*ruby-graphviz \(([0-9.]+)\)/.match(`cat #{Rails.root.join 'Gemfile.lock'}`)[1]
end
end

To elaborate on tsiruu answer: in case you are using rails, just take his code and put it in an initializer
unless defined? StateMachine::Machine::Constants::RGV_VERSION
warn "StateMachine::Machine::Constants overriden in #{__FILE__}"
class StateMachine::Machine::Constants
RGV_VERSION = /^[ ]*ruby-graphviz \(([0-9.]+)\)/.match(`cat #{Rails.root.join 'Gemfile.lock'}`)[1]
end
end

Related

Rails-ERD, Graphviz error. Other answers not working. "Saving diagram failed! Verify that Graphviz is installed and in your path, or use filetype=dot"

I am on Rails 5.1, and on a Mac running Sierra. I've already read and tried the solutions listed on other similar questions (1, 2). I have 3 different Rails projects that I'm working on and have rails-erd installed on all of them, but it is not working on one of them.
When I run rails ert --trace:
>rails erd --trace
** Invoke erd (first_time)
** Invoke erd:generate (first_time)
** Invoke erd:check_dependencies (first_time)
** Execute erd:check_dependencies
** Invoke erd:options (first_time)
** Execute erd:options
** Invoke erd:load_models (first_time)
** Execute erd:load_models
Loading application environment...
** Invoke environment (first_time)
** Execute environment
Loading code in search of Active Record models...
** Execute erd:generate
Generating Entity-Relationship Diagram for 13 models...
rails aborted!
Saving diagram failed!
Verify that Graphviz is installed and in your path, or use filetype=dot.
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram/graphviz.rb:211:in `rescue in block in <class:Graphviz>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram/graphviz.rb:202:in `block in <class:Graphviz>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram.rb:169:in `instance_eval'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram.rb:169:in `save'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram.rb:120:in `create'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram.rb:74:in `create'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/tasks.rake:55:in `block (2 levels) in <top (required)>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:216:in `block in invoke_prerequisites'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:214:in `each'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:214:in `invoke_prerequisites'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:193:in `block in invoke_with_call_chain'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/command.rb:46:in `invoke'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/commands.rb:16:in `<top (required)>'
/Users/jaysonwhelpley/Sites/biq/bin/rails:9:in `require'
/Users/jaysonwhelpley/Sites/biq/bin/rails:9:in `<top (required)>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/Users/jaysonwhelpley/Sites/biq/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
NoMethodError: undefined method `zero?' for nil:NilClass
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/ruby-graphviz-1.2.3/lib/graphviz/utils.rb:58:in `output_from_command'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/ruby-graphviz-1.2.3/lib/graphviz.rb:600:in `output'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram/graphviz.rb:204:in `block in <class:Graphviz>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram.rb:169:in `instance_eval'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram.rb:169:in `save'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram.rb:120:in `create'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/diagram.rb:74:in `create'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails-erd-1.5.2/lib/rails_erd/tasks.rake:55:in `block (2 levels) in <top (required)>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:216:in `block in invoke_prerequisites'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:214:in `each'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:214:in `invoke_prerequisites'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:193:in `block in invoke_with_call_chain'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/commands/rake/rake_command.rb:21:in `block in perform'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/command.rb:46:in `invoke'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/commands.rb:16:in `<top (required)>'
/Users/jaysonwhelpley/Sites/biq/bin/rails:9:in `require'
/Users/jaysonwhelpley/Sites/biq/bin/rails:9:in `<top (required)>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/Users/jaysonwhelpley/.rbenv/versions/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/Users/jaysonwhelpley/Sites/biq/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => erd => erd:generate
I have already installed graphviz.
The rake erd filetype=dot command works just fine, but trying the option of using:
erd --inheritance --direct --attributes=foreign_keys,content --filetype=dot
dot -Tjpg erd.dot > erd.jpg
It just creates an empty erd.jpg.
Any help?
I was having a similar problem, what I did was the following:
Put the following patch on initializers, you can find the explanation here ERD issue:
require 'rails_erd/domain/relationship'
module RailsERD
class Domain
class Relationship
class << self
private
def association_identity(association)
Set[association_owner(association), association_target(association)]
end
end
end
end
end
Generate the dot file
rake erd filetype=dot --trace
Generate the pdf file
dot -Tpdf -oERD.pdf -v erd.dot

Errno::EACCES: Permission denied # unlink_internal - E:/work/testing/db/test.sqlite3 [duplicate]

I am doing the draft version of the railstutorial, when I try to run bundle exec rake test:models I get this error message:
rake aborted!
Errno::EACCES: Permission denied - C:/Users/Alex/Desktop/Workspace/Rails/sample_
app/db/test.sqlite3
C:/Users/Alex/Desktop/Workspace/Rails/sample_app/test/test_helper.rb:3:in `<top
(required)>'
C:/Users/Alex/Desktop/Workspace/Rails/sample_app/test/helpers/application_helper
_test.rb:1:in `<top (required)>'
Tasks: TOP => test:run => test:units
(See full trace by running task with --trace)
With --trace:
** Invoke test (first_time)
** Execute test
** Invoke test:run (first_time)
** Invoke test:units (first_time)
** Invoke test:prepare (first_time)
** Execute test:prepare
** Execute test:units
rake aborted!
Errno::EACCES: Permission denied - C:/Users/Alex/Desktop/Workspace/Rails/sample_
app/db/test.sqlite3
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:1432:in `unlink'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:1432:in `block in remove
_file'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:1440:in `platform_suppor
t'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:1431:in `remove_file'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:785:in `remove_file'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:563:in `block in rm'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:562:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/fileutils.rb:562:in `rm'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/sqlite_database_tasks.rb:22:in `drop'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/sqlite_database_tasks.rb:26:in `purge'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:159:in `purge'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:201:in `load_schema_for'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:216:in `block in load_schema_current'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:255:in `block in each_current_configurat
ion'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:254:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:254:in `each_current_configuration'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/tasks/database_tasks.rb:215:in `load_schema_current'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:402:in `load_schema_if_pending!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:409:in `block in maintain_test_schema!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:637:in `suppress_messages'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:414:in `method_missing'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4.2.0.beta1/li
b/active_record/migration.rb:409:in `maintain_test_schema!'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_help.rb:19:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `block in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:233:in `load_dependency'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/Users/Alex/Desktop/Workspace/Rails/sample_app/test/test_helper.rb:3:in `<top
(required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `block in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:233:in `load_dependency'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/Users/Alex/Desktop/Workspace/Rails/sample_app/test/helpers/application_helper
_test.rb:1:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `block in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:233:in `load_dependency'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-4.2.0.beta1/l
ib/active_support/dependencies.rb:248:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:114:in `block (3 levels) in define'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:114:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:114:in `block (2 levels) in define'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:113:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:113:in `block in define'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:240:in `call'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:240:in `block in execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:235:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:235:in `execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:179:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:201:in `block in invoke_prerequisites'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:199:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:199:in `invoke_prerequisites'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:178:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:165:in `invoke'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/sub_test_task.rb:20:in `invoke_rake_task'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.2.0.beta1/lib/ra
ils/test_unit/testing.rake:8:in `block in <top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:240:in `call'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:240:in `block in execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:235:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:235:in `execute'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:179:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:172:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/task.r
b:165:in `invoke'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:150:in `invoke_task'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:106:in `block in top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:115:in `run_with_threads'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:100:in `top_level'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:78:in `block in run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:176:in `standard_exception_handling'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/lib/rake/applic
ation.rb:75:in `run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.3.2/bin/rake:33:in
`<top (required)>'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `load'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `<main>'
Tasks: TOP => test:run => test:units
I have tried checking the permissions on my db folder, and also tried to restart everything. I am using rails version 4.2.0beta1 on windows. The problem started when I made the "User" model. I tried rolling back and migrating up again as well.
Edit:
It seems that my test database is corrupted in some way. If I change the /config/database.yml test: to /db/development.sqlite the tests work.
I deleted the old test.sqlite3 and replaced it with a copy of development.sqlite3 and renamed it test.sqlite3, this seems to have solved the problem.
Run rake db:migrate RAILS_ENV=test before running the tests.
I'm not a rails expert, so I don't know if the test DB should be migrated automatically when migrating the development DB, but this will migrate it, and it resolved my similar problem.
Note: My OS is Windows 8.1
Yes, the issue is with Windows. when you read the code for fileutils.rb found in railsinstaller directory. It wants to unlink and want to give permission 700(which is found in unix/linux) but not in windows. so will not work.
Here is the snippet from the fileutil.rb file.
def remove_file
platform_support {
File.unlink path
}
end
def platform_support
return yield unless fu_windows?
first_time_p = true
begin
yield
rescue Errno::ENOENT
raise
rescue => err
if first_time_p
first_time_p = false
begin
File.chmod 0700, path() # Windows does not have symlink
retry
rescue SystemCallError
end
end
raise err
end
end
I noticed this happens if I have one terminal open running the rails server and another terminal to work on. My work Terminal is what gives me the issue when I try to drop or reset a database. I close the server ans try again and it works fine.

uninitialized constant ActionController::Caching::Sweeper

When precompiling production environment I receive an uninitialized constant ActionController::Caching::Sweeper error (same with heroku). In the development environment and with localhost everything is working fine. Thx for any suggestions.
C:\Sites\code\myapp>bundle exec rake assets:precompile RAILS_ENV=production --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant ActionController::Caching::Sweeper
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/spree_reviews-5447d2231446/app/models/spree/review_sweeper.rb:1:in `<top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
C:in `eager_load!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:150:in `block in tsort_each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:219:in `each_strongly_connected_component_from'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:182:in `block in each_strongly_connected_component'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:180:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:180:in `each_strongly_connected_component'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/tsort.rb:148:in `tsort_each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
C:/Sites/code/farmfood/config/environment.rb:5:in `<top (required)>'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:197:in `block in invoke_prerequisites'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:195:in `invoke_prerequisites'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:174:in `block in invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `load'
C:/RailsInstaller/Ruby1.9.3/bin/rake:23:in `<main>'
Tasks: TOP => environment
This is due to a bug in the rails-observers gem. The bug has been fixed, but the fix has not yet reached rubygems.org.
Use the version of rails-observers from GitHub, by replacing this line in your Gemfile:
gem 'rails-observers'
With this one:
gem 'rails-observers', git: 'https://github.com/rails/rails-observers.git'
This is a bug in rails-observers. https://github.com/rails/rails-observers/issues/4
Thx #khustochka to bringing me on the right track
I solved my problem with:
Installing the gem 'rails-observers'
https://github.com/rails/rails-observers
Then I added to production.rb
config.dependency_loading = true if $rails_rake_task
config.active_record.observers = :contact_observer
Since I got uninitialized constant ActiveModel::Observer error
I created in app/models the file contact_observe.rb
class ContactObserver < ActiveRecord::Observer
observe :user
end
after I did rake db:migrate RAILS_ENV=production
and rake asset precompile RAILS_ENV=production
and my problem was fixed
This is happening because the spree_reviews extension is depending on a feature of Rails which has been removed in Rails 4. Please file an issue on that project about this problem.

Could not find table by rake routes on production server

When checking routes on production server with rake routes, there is an error of Could not find table 'authentify_engine_configs' which is a table in the database. What could cause this error? The following is full trace:
cjadmin#ubuntu-ibm:/var/www/nbhyop/current$ bundle exec rake routes --trace
** Invoke routes (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Could not find table 'authentify_engine_configs'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:472:in `table_structure'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in `columns'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/model_schema.rb:228:in `yield'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/model_schema.rb:228:in `default'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/model_schema.rb:228:in `columns'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/model_schema.rb:237:in `columns_hash'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/locking/optimistic.rb:129:in `locking_enabled?'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/relation.rb:170:in `exec_queries'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/relation.rb:160:in `block in to_a'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/explain.rb:33:in `logging_query_plan'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/relation.rb:159:in `to_a'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/relation/finder_methods.rb:378:in `find_first'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.12/lib/active_record/relation/finder_methods.rb:122:in `first'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/bundler/gems/authentify-6d86f5486c71/app/custom/authentify/authentify_utility.rb:85:in `find_config_const'
/var/www/nbhyop/releases/20130514202149/config/initializers/my_constants.rb:7:in `<top (required)>'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `block in load'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/engine.rb:587:in `each'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/engine.rb:587:in `block in <class:Engine>'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/www/nbhyop/releases/20130514202149/config/environment.rb:6:in `<top (required)>'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/application.rb:103:in `require'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/application.rb:103:in `require_environment!'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.12/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/home/cjadmin/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:205:in `block in invoke_prerequisites'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:203:in `each'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:203:in `invoke_prerequisites'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:183:in `block in invoke_with_call_chain'
/home/cjadmin/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `load'
/home/cjadmin/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `<main>'
Tasks: TOP => routes => environment
cjadmin#ubuntu-ibm:/var/www/nbhyop/current$
It is rails 3.2.12 app running on ubuntu with nginx and passenger. rake db:migrate has the same error.
Thanks for help.
If it really is production then you need to tell rails, otherwise it will use development by default
RAILS_ENV=production bundle exec rake routes

Upgrading an app to Rails 3.1.0.beta1

I'm attempting to update my existing rails app (3.0.3) to 3.1.0.beta1. I've install the rails gem and ran the bundle command to pull in all of the updated gems. When I run rake rails:update though I get:
rake aborted!
undefined method `join_asset_file_contents' for module `ActionView::Helpers::AssetTagHelper'
What am I doing wrong?
Trace Output
rake aborted!
undefined method `join_asset_file_contents' for module `ActionView::Helpers::AssetTagHelper'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.beta1/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.beta1/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/smurf-1.0.6/lib/smurf.rb:15:in `<module:AssetTagHelper>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/smurf-1.0.6/lib/smurf.rb:5:in `<top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `require'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `block in require'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `require'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.13/lib/bundler.rb:120:in `require'
/Users/Kyle/Desktop/skateparks-web/config/application.rb:7:in `<top (required)>'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/Kyle/Desktop/skateparks-web/Rakefile:1:in `<top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2017:in `block in load_rakefile'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2000:in `block in run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'
After removing the Smurf Gem
DEPRECATION WARNING: class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first. (called from <top (required)> at /Users/Kyle/Desktop/skateparks-web/config/application.rb:7)
DEPRECATION WARNING: class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first. (called from <top (required)> at /Users/Kyle/Desktop/skateparks-web/config/application.rb:7)
** Invoke rails:update (first_time)
** Invoke rails:update:configs (first_time)
** Execute rails:update:configs
conflict config/boot.rb
Overwrite /Users/Kyle/Desktop/skateparks-web/config/boot.rb? (enter "h" for help) [Ynaqdh] y
force config/boot.rb
exist config
conflict config/routes.rb
Overwrite /Users/Kyle/Desktop/skateparks-web/config/routes.rb? (enter "h" for help) [Ynaqdh] n
skip config/routes.rb
conflict config/application.rb
Overwrite /Users/Kyle/Desktop/skateparks-web/config/application.rb? (enter "h" for help) [Ynaqdh] y
force config/application.rb
identical config/environment.rb
** Invoke rails:update:javascripts (first_time)
** Execute rails:update:javascripts
rake aborted!
undefined method `create_javascript_files' for #<Rails::Generators::AppGenerator:0x00000100fbb160>
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.beta1/lib/rails/tasks/framework.rake:40:in `invoke_from_app_generator'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.0.beta1/lib/rails/tasks/framework.rake:63:in `block (3 levels) in <top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:607:in `block in invoke_prerequisites'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:596:in `block in invoke_with_call_chain'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/Users/Kyle/.rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'
join_asset_file_contents method is moved from
actionpack/lib/action_view/helpers/asset_tag_helper.rb
to
actionpack/lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb
That is the reason why you see this error.
Can you please run the rake command with --trace to see why join_asset_file_contents is being executed in the call graph?

Resources