_localization suffix for models reserved in FactoryGirl - ruby-on-rails-3

I have two models in my Rails application:
class Item < ActiveRecord::Base
end
class ItemLocalization < ActiveRecord::Base
end
Similarly, I have two factories:
factory :item do
sequence(:name) { |n| "item #{n}" }
description "this is a description"
association :locale, :factory => :locale_deCH
item_group
end
factory :item_localization do
sequence(:name) { |n| "item #{n}" }
description "this is a description"
association :locale, :factory => :locale_deCH
item
user
reviewer
end
When having a second factory with the _localization suffix, FactoryGirl returns a DuplicationError:
Rack::File headers parameter replaces cache_control after Rack 1.5.
/Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/decorator.rb:10:in `method_missing': Factory already registered: item_localization (FactoryGirl::DuplicateDefinitionError)
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/decorator/disallows_duplicates_registry.rb:6:in `register'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl.rb:65:in `block in register_factory'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl.rb:64:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl.rb:64:in `register_factory'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:20:in `factory'
from /Users/user/Sites/ec/spec/factories.rb:62:in `block in <top (required)>'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:49:in `instance_eval'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:49:in `run'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/syntax/default.rb:7:in `define'
from /Users/user/Sites/ec/spec/factories.rb:1:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `block in load'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/find_definitions.rb:16:in `block in find_definitions'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/find_definitions.rb:15:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl-4.1.0/lib/factory_girl/find_definitions.rb:15:in `find_definitions'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/factory_girl_rails-4.1.0/lib/factory_girl_rails/railtie.rb:26:in `block in <class:Railtie>'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:34:in `call'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/railties-3.2.11/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/user/Sites/ec/config/environment.rb:5:in `<top (required)>'
from /Users/user/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/user/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/user/Sites/ec/spec/spec_helper.rb:3:in `<top (required)>'
from /Users/user/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/user/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/user/Sites/ec/spec/models/organization_spec.rb:1:in `<top (required)>'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `each'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in `load_spec_files'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/rspec-core-2.12.2/lib/rspec/core/command_line.rb:22:in `run'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:80:in `run'
from /Users/user/.rvm/gems/ruby-1.9.3-p327#rails329-ec/gems/rspec-core-2.12.2/lib/rspec/core/runner.rb:17:in `block in autorun'
Is the suffix "_localization" somehow reserved? Rails doesn't seem to have an issue with it.

I found the problem. It had nothing to do with the "_localization" suffix. Rather, when creating the model ItemLocalization, Rails created a factory with the same name in the folder test/factories and I used the same factory under rspec/factories.
Removing all files from the test/factories folder solved the issue.

Related

ruby on rails query on jsonb field does not work

I have a table in the PostgreSQL 9.5 with jsonb column called segmented_data and I have a record with some data in this field
ProjectKeyword.first
=> #<ProjectKeyword:0x007fa83a17e7f8 id: 2201, project_id: 79, keyword_id: 2201, segmented_data: {"keyword_value"=>"land for sale", "dimension_value"=>{"Property type"=>"Land"}}>
How I can find this record in the database by value of one of the keyw of segmented_data?
I have tried:
ProjectKeyword.where("segmented_data ->> 'keyword_value' = 'land for sale'").first
=> nil
ProjectKeyword.where('segmented_data #> ?', {keyword_value: 'land for sale'}.to_json).first
=> nil
ProjectKeyword.where('segmented_data #> ? ', '{"keyword_value":"land for sale"}' ).first
=> nil
What am I doing wrong in these queryes?
EDITED
My Model
class ProjectKeyword < ApplicationRecord
serialize :segmented_data, JSON
belongs_to :project
belongs_to :keyword
has_many :project_keyword_dimensions
has_many :dimensions, through: :project_keyword_dimensions
validates :project_id, :keyword_id, presence: true
end
Migration
class AddSegemtnedDataToProjectKeywords < ActiveRecord::Migration[5.0]
def change
add_column :project_keywords, :segmented_data, :jsonb, default: '{}'
add_index :project_keywords, :segmented_data, using: :gin
end
end
EDITED
I think I found a possible reason of this problem
My db schema still was not in sql format and I added this line
config.active_record.schema_format = :sql
into application.rb file
But now if i running command
bundle exec rake db:migrate --trace
I get this error
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:structure:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:structure:dump
I, [2016-06-21T08:09:14.083751 #51538] INFO -- : [Rollbar] Scheduling item
I, [2016-06-21T08:09:14.102300 #51538] INFO -- : [Rollbar] Details: https://rollbar.com/instance/uuid?uuid=fgfffgf (only available if report was successful)
rake aborted!
TypeError: no implicit conversion of nil into String
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/postgresql_database_tasks.rb:99:in `system'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/postgresql_database_tasks.rb:99:in `run_cmd'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/postgresql_database_tasks.rb:64:in `structure_dump'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/tasks/database_tasks.rb:207:in `structure_dump'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/railties/databases.rake:292:in `block (3 levels) in <top (required)>'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:248:in `block in execute'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:243:in `each'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:243:in `execute'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:173:in `invoke'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/railties/databases.rake:67:in `block (2 levels) in <top (required)>'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:248:in `block in execute'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:243:in `each'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:243:in `execute'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:173:in `invoke'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.rc1/lib/active_record/railties/databases.rake:59:in `block (2 levels) in <top (required)>'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:248:in `block in execute'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:243:in `each'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:243:in `execute'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/task.rb:173:in `invoke'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:152:in `invoke_task'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:108:in `each'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:108:in `block in top_level'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:117:in `run_with_threads'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:102:in `top_level'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:80:in `block in run'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
/Users/atrthur/.rbenv/versions/2.3.1/bin/rake:23:in `load'
/Users/atrthur/.rbenv/versions/2.3.1/bin/rake:23:in `<top (required)>'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
/Users/atrthur/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
/Users/atrthur/.rbenv/versions/2.3.1/bin/bundle:23:in `load'
/Users/atrthur/.rbenv/versions/2.3.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:structure:dump
What is wrong with it? How to fix it?
Solution for this problem was to remove this line
serialize :segmented_data, JSON
from model ProjectKeyword
After this line was removed all queries started to work, only the problem now that the default value of : segmented_data is not the hash anymore, it became a string '{}'
So before you update data in this field I have to assign hash value to this field
project_keyword.segmented_data = {}
project_keyword.save!

Each loop in test forgeting variables

I have a problem testing my rails app. I have this code for my tests:
describe Categoria do
let(:categoria) { FactoryGirl.create(:categoria) }
it { should be_valid }
describe "agregar campos" do
before { #campo = categoria.campos.build(nombre: "campo1", tipo_campo: "check_box") }
it { #campo.should be_valid }
it { #campo.should respond_to :nombre }
it { #campo.should respond_to :tipo_campo }
it { #campo.should respond_to :requerido }
describe "valores válidos" do
valores = %w[texto texto_extenso numero decimal check_box]
valores.each do |valido|
#campo.tipo_campo = valido
#campo.should be_valid
end
end
end
end
If I run the tests without the block "valores válidos" an all the other tests pass, but when I run all the tests, I get this error:
Rack::File headers parameter replaces cache_control after Rack 1.5.
Exception encountered: #<NoMethodError: undefined method `tipo_campo=' for nil:NilClass>
backtrace:
/home/alejo/proyectos/lachiquitienda/spec/models/categoria_spec.rb:38:in `block (4 levels) in <top (required)>'
/home/alejo/proyectos/lachiquitienda/spec/models/categoria_spec.rb:37:in `each'
/home/alejo/proyectos/lachiquitienda/spec/models/categoria_spec.rb:37:in `block (3 levels) in <top (required)>'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe'
/home/alejo/proyectos/lachiquitienda/spec/models/categoria_spec.rb:35:in `block (2 levels) in <top (required)>'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe'
/home/alejo/proyectos/lachiquitienda/spec/models/categoria_spec.rb:27:in `block in <top (required)>'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `module_eval'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in `subclass'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in `describe'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/dsl.rb:18:in `describe'
/home/alejo/proyectos/lachiquitienda/spec/models/categoria_spec.rb:5:in `<top (required)>'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `block in load'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/spork-0.9.2/lib/spork/test_framework/rspec.rb:11:in `run_tests'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:13:in `block in run'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
/home/alejo/.rvm/gems/ruby-1.9.3-p374/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/home/alejo/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/home/alejo/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/home/alejo/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/home/alejo/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/home/alejo/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
[Finished in 5.9s]
Why is #campo nil iniside the each loop?
Thanks in advance
Because you are not inside the context of a test when you are trying to access it.
All your other tests are marked with it { } blocks (rspec will also accept specify { } blocks) - your loop does not define any tests.
Try something like the following:
describe "valores válidos" do
valores = %w[texto texto_extenso numero decimal check_box]
valores.each do |valido|
it "allows the value #{valido}" do # put your own translation in here!
#campo.tipo_campo = valido
#campo.should be_valid
end
end
end
Now your assignments are inside tests and the variable #campo will be defined.

rake aborted! undefined method `map' for :name:Symbol

I'm trying to pass arguments to a Rake task and access my model as mentioned in "How to pass command line arguments to a rake task" and "Do rails rake tasks provide access to ActiveRecord models?".
However adding => :environment to this code:
require 'rake'
namespace :genre do
desc "Add a genre"
task :add, :genre_id, :name => :environment do |t, args|
puts args.name
end
end
Gives me this error when I run the task:
rake genre:add['1','Abc']
rake aborted!
undefined method `map' for :name:Symbol
(See full trace by running task with --trace)
If I delete => :environment it works just fine.
UPDATE:
TRACE:
rake --trace genre:add['1','Abc']
rake aborted!
undefined method `map' for :name:Symbol
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:254:in `set_arg_names'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task_manager.rb:29:in `define_task'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task.rb:310:in `define_task'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:32:in `task'
/private/var/www/html/someapp.com/subdomains/someapp.heroku.com/someapp/lib/tasks/genre.rake:5:in `block in <top (required)>'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/task_manager.rb:207:in `in_namespace'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb:102:in `namespace'
/private/var/www/html/someapp.com/subdomains/someapp.heroku.com/someapp/lib/tasks/genre.rake:3:in `<top (required)>'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:425:in `load'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:425:in `block in load_tasks'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:425:in `each'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:425:in `load_tasks'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:145:in `load_tasks'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/private/var/www/html/someapp.com/subdomains/someapp.heroku.com/someapp/Rakefile:7:in `<top (required)>'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/user/.rvm/gems/ruby-1.9.2-p318/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/user/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `load'
/Users/user/.rvm/gems/ruby-1.9.2-p318/bin/rake:19:in `<main>'
Looks like your syntax is off. Try:
task :add, [:genre_id, :name] => :environment do |t, args|

Inject route from gem to rails 3 routes.rb using Railties (devise issue)

I would like to automatically inject a route from my gem to the host app using a railtie. So far I have something like this:
module Fabes
class FabesRailtie < ::Rails::Railtie
ActionController::Base.send :include, Fabes::Helper
ActionController::Base.helper Fabes::Helper
initializer 'fabes.routes', after: :after_initialize do |app|
app.routes.draw do
match '/fabes' => Fabes::Admin, as: :fabes_admin
end
end
end
end
This is working (is getting called from the host app) but when I try to access the /fabes route or just list the routes, it is failing with a devise error:
fuzzyalej#fuzzyalej:~/code/fabes-rails-example (master *)$ rake routes --trace
** Invoke routes (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `failure_app=' for nil:NilClass
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/devise-2.1.2/lib/devise.rb:406:in `configure_warden!'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/devise-2.1.2/lib/devise/rails/routes.rb:20:in `finalize_with_devise!'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/routing/route_set.rb:261:in `draw'
/Users/fuzzyalej/code/fabes/lib/fabes/railtie.rb:7:in `block in <class:FabesRailtie>'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `instance_exec'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `run'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `each'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `run_initializers'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:136:in `initialize!'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/fuzzyalej/code/fabes-rails-example/config/environment.rb:5:in `<top (required)>'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:103:in `require_environment!'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/bin/rake:23:in `load'
/Users/fuzzyalej/.rbenv/versions/1.9.3-p194/bin/rake:23:in `<main>'
Tasks: TOP => routes => environment
I don't know if I can inject a route directly like this or instead I would have to use a generator..
Any thoughts on the issue?
Defining your routes in your gem's route.rb file and then mounting the engine is the way to go in this case.
The "official guide":
http://edgeguides.rubyonrails.org/engines.html
And of course, there's a RailsCast episode covering what you likely need:
http://railscasts.com/episodes/277-mountable-engines
Hope this helps.

Rails: Custom Rake Task error => rake aborted! missing :controller

(RoR with Rails 3.1, gem rake 0.9.2.2)
I'm trying to run the most basic custom rake task as you can see here:
task :update_me => :environment do
Product.all.each do |product|
puts product.link
end
end
I keep getting the error below. The task will run if I just print out hello world and take out the ":environment" part. My rake task seems to be having trouble with the ":environment" part of this, but I need this to access my models.
rake aborted!
missing :controller
Tasks: TOP => update_me => environment
(See full trace by running task with --trace)
trace:
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:179:in `default_controller_and_action'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:76:in `normalize_options!'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:59:in `initialize'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1302:in `new'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1302:in `add_route'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1282:in `decomposed_match'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1268:in `block in match'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1268:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1268:in `match'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:505:in `map_method'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:467:in `get'
/home/ubuntu/code/preevio/config/routes.rb:35:in `block in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:260:in `draw'
/home/ubuntu/code/preevio/config/routes.rb:1:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `block in load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:16:in `reload!'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/file_update_checker.rb:78:in `call'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/file_update_checker.rb:78:in `execute'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:27:in `updater'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/ubuntu/code/preevio/config/environment.rb:5:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application.rb:103:in `require_environment!'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/railties-3.2.3/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/bin/rake:19:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290#rails31/bin/rake:19:in `<main>'
The backtrace seems to indicate an error in the routes file, which is loaded when you require the environment.
In these cases, running rake routes will bring further information on the problem.