ckeditor in Rails 3.0.9 - ruby-on-rails-3

i have my project with Rails 3.0.9 and i added the CKeditor 3.6.3, in development works fine, and in Staging in Heroku works fine too, but in Production crash the app.
This are the configuration i have to production:
config/application.rb
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
config/environments/production.rb
#config.assets.precompile += Ckeditor.assets
I have commented the line because config.assets is not available until Rails 3.1, but i don't want to upgrade Rails in this moment.
app/models/ckeditor/attachment_file.rb
class Ckeditor::AttachmentFile < Ckeditor::Asset
has_attached_file :data,
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => ":attachment/:id/:style.:extension",
:url => ":s3_domain_url"
validates_attachment_size :data, :less_than => 100.megabytes
validates_attachment_presence :data
def url_thumb
#url_thumb ||= Ckeditor::Utils.filethumb(filename)
end
end
app/models/ckeditor/picture.rb
class Ckeditor::Picture < Ckeditor::Asset
has_attached_file :data, :styles => { :content => '800>', :thumb => '118x100#' },
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => ":picture/:id/:style.:extension",
:url => ":s3_domain_url"
validates_attachment_size :data, :less_than => 2.megabytes
validates_attachment_presence :data
def url_content
url(:content)
end
end
And i received the next error:
/home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library': uninitialized constant Ckeditor::Asset (NameError)
from /home/jorge/trabajos/blanet/app/models/ckeditor/attachment_file.rb:1:in `<top (required)>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/engine.rb:137:in `each'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/engine.rb:137:in `block in eager_load!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/engine.rb:135:in `each'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/engine.rb:135:in `eager_load!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/application.rb:108:in `eager_load!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `block in run_initializers'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
from /home/jorge/trabajos/blanet/config/environment.rb:5:in `<top (required)>'
from /home/jorge/trabajos/blanet/config.ru:3:in `block in <main>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
from /home/jorge/trabajos/blanet/config.ru:1:in `new'
from /home/jorge/trabajos/blanet/config.ru:1:in `<main>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/rack-1.2.3/lib/rack/server.rb:162:in `app'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/rack-1.2.3/lib/rack/server.rb:204:in `start'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/commands/server.rb:65:in `start'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/commands.rb:30:in `block in <top (required)>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290#rails3/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Any one can help me?
Thanks for advance.

It looks like it can't load the parent class for your attachments. Is Ckeditor::Asset defined somewhere? Is it being loaded? Maybe you need a require ckeditor/asset somewhere?

Related

'rake db:migrate' is not working correctly. Not creating tables in my simple_cms in my model

Here is what I did:
1. rails generate migration DoNothingYet
invoke active_record
20160919195736_do_nothing_yet.rb
rails generate model User
invoke active_record
create db/migrate/20160919201440_create_users.rb
create app/models/user.rb
invoke test_unit
create test/models/user_test.rb
create test/fixtures/users.yml
Here's the two files I created and edited:
class DoNothingYet < ActiveRecord::Migration
def up
end
def down
end
end
class CreateUsers < ActiveRecord::Migration
def up
`create_table :users do |t|`
`t.column "first_name", :string, :limit => 25`
`t.string "last_name", :limit => 50`
t.string "email", :default => "", :null => false
t.string "password", :limit => 40
#t.dateime "created_at"
#t.datetime "updated_at"
t.timestamps
end
end
def down
drop_table :users
end
end
When I run: rake db:migrate
It does not return anything. When I run rake db:migrate --trace
I get back:
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:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump
When I log in mysql to my simple_cms_development database via my Username- simple_cms.
I try SHOW TABLES;
No tables appeared.
When I run rake db:schema:load --trace this is what I get:
JohnMicttesMBP5:simple_cms john-michaelnalettenalette$ rake db:schema:load --trace
** Invoke db:schema:load (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:load
-- create_table("users", {:force=>:cascade})
-> 0.1929s
-- initialize_schema_migrations_table()
-> 0.1518s
-- create_table("users", {:force=>:cascade})
rake aborted!
Mysql2::Error: Access denied for user 'simple_cms'#'localhost' to database 'test'
/Users/john-michaelnalettenalette/simple_cms/vendor/bundle/gems/mysql2- 0.3.21/lib/mysql2/client.rb:70:in `connect'
/Users/john-michaelnalettenalette/simple_cms/vendor/bundle/gems/mysql2-0.3.21/lib/mysql2/client.rb:70:in `initialize'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:438 :in `new_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:448 :in `checkout_new_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:422 :in `acquire_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:349 :in `block in checkout'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/m onitor.rb:211:in `mon_synchronize'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:348 :in `checkout'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:263 :in `block in connection'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/m onitor.rb:211:in `mon_synchronize'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:262 :in `connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:567 :in `retrieve_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/connection_handling.rb:87:in `connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/migration.rb:646:in `connection'
/Library/Ruby/Gems/2.0.0/gems/activerecord-c 4.2.2/lib/active_record/migration.rb:661:in `block in method_missing'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/migration.rb:632:in `block in say_with_time'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/b enchmark.rb:281:in `measure'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/migration.rb:632:in `say_with_time'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/migration.rb:652:in `method_missing'
/Users/john-michaelnalettenalette/simple_cms/db/schema.rb:16:in `block in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/schema.rb:41:in `instance_eval'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/schema.rb:41:in `define'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/schema.rb:61:in `define'
/Users/john-michaelnalettenalette/simple_cms/db/schema.rb:14:in `<top (required)>'
/Library/Ruby/Gems/2.0.0/gems/activesupport- 4.2.2/lib/active_support/dependencies.rb:268:in `load'
/Library/Ruby/Gems/2.0.0/gems/activesupport- 4.2.2/lib/active_support/dependencies.rb:268:in `block in load'
/Library/Ruby/Gems/2.0.0/gems/activesupport- 4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
/Library/Ruby/Gems/2.0.0/gems/activesupport- 4.2.2/lib/active_support/dependencies.rb:268:in `load'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/tasks/database_tasks.rb:218:in `load_schema_for'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/tasks/database_tasks.rb:235:in `block in load_schema_current'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/tasks/database_tasks.rb:274:in `each'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/tasks/database_tasks.rb:234:in `load_schema_current'
/Library/Ruby/Gems/2.0.0/gems/activerecord- 4.2.2/lib/active_record/railties/databases.rake:244:in `block (3 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:248:in `call'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:248:in `block in execute'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:243:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:243:in `execute'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/m onitor.rb:211:in `mon_synchronize'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/task.rb:173:in `invoke'
/Library/Ruby/Gems/2.0.0/gems/rake- 11.2.2/lib/rake/application.rb:152:in `invoke_task'
/Library/Ruby/Gems/2.0.0/gems/rake- 11.2.2/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:108:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:108:in `block in top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:117:in `run_with_threads'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:102:in `top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:80:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
/usr/bin/rake:37:in `<main>'
Tasks: TOP => db:schema:load
Any suggestions would be appreciated?
#John-Michael Nalette Have you checked whether the password in the database.yml is correct for the database simple_cms and also if your user has the login to the database.

_localization suffix for models reserved in FactoryGirl

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.

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|

Getting an error with custom validation in a Rails 3 ActiveModel

I'm trying to use the Date Validator Gem but I am running into an error and I'm not sure if it's because the model isn't Active Record or not (I've seen people suggest that validation is a bit funky in ActiveModel when not in ActiveRecord).
I am using Ruby 1.9.2 & Rails 3.0.7. I've attached both the class and the error below.
Thanks in advance for any help!
Class
require 'ice_cube'
require 'active_support'
require 'active_support/time_with_zone'
require 'ostruct'
require 'tzinfo'
require 'active_model'
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
class Schedule
attr_accessor :yaml, :repeat, :interval, :interval_unit, :start_time, :start_date, :end_date, :end_time, :ends, :on, :after, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday
validates_presence_of :repeat, :start_date, :start_time, :end_date, :end_time, :ends
validates_presence_of :interval, :interval_unit, :if => :ends_never?
validates_presence_of :on, :if => :ends_on_date?
validates_numericality_of :after, :greater_than => 0, :if => :ends_after_recurrences?
validates :start_date, :date => { :after => Time.now }
validates :end_date, :date => { :after => :start_date }
validates :on, :date => { :after => :end_date }
def initialize(attributes = {})
end
def persisted?
false
end
private
def parse_schedule
if :repeat == 0
get_repeatable
end
end
def parse_yaml
end
def ends_on_date?
return :ends == "on"
end
def ends_never?
return :ends == "never"
end
def ends_after_recurrences?
return :ends == "after"
end
end
Error from Rails Console
ruby-1.9.2-p180 :001 > s = Schedule.new
NoMethodError: undefined method `new' for DateValidator:Module
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.7/lib/active_model/validations/with.rb:70:in `block in validates_with'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.7/lib/active_model/validations/with.rb:69:in `each'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.7/lib/active_model/validations/with.rb:69:in `validates_with'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.7/lib/active_model/validations/validates.rb:90:in `block in validates'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.7/lib/active_model/validations/validates.rb:83:in `each'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.7/lib/active_model/validations/validates.rb:83:in `validates'
from /Users/chance/Sites/EatingNow/app/models/schedule.rb:16:in `<class:Schedule>'
from /Users/chance/Sites/EatingNow/app/models/schedule.rb:10:in `<top (required)>'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:454:in `load'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:454:in `block in load_file'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:453:in `load_file'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:340:in `require_or_load'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:491:in `load_missing_constant'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:183:in `block in const_missing'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:181:in `each'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:181:in `const_missing'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.1/lib/rspec/core/backward_compatibility.rb:20:in `const_missing'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/rspec-expectations-2.5.0/lib/rspec/expectations/backward_compatibility.rb:6:in `const_missing'
from (irb):1
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start'
from /Users/chance/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
You have included/extended the top-level namespace. Make sure the includes/extends are IN the class.
class Schedule
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming

Rails 3 Setting Up Action Mailer

Everything was going so well...
gem 'mail' is installed
enter > $ rails g scaffold user name:string email:string
enter > $ rake db:migrate (fine I can see it on http://localhost:3000/users/new) then...
enter > $ rails g mailer user_mailer
On this command I get this huge error - what is it and how do I resolve it?
Users/mailer_app/config/initializers/setup_mail.rb:14: uninitialized
constant DevelopmentMailInterceptor (NameError)
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/engine.rb:201
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/engine.rb:200:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/engine.rb:200
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `instance_exec'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:50:in `run_initializers'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `run_initializers'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:134:in `initialize!'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing'
from /Users/liam_carey/Documents/Aptana Studio 3 Workspace/mailer_test/config/environment.rb:5
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:103:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/application.rb:103:in `require_environment!'
from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.5/lib/rails/commands.rb:16
from script/rails:6:in `require'
from script/rails:6
user:mailer_app $
Here is the contents of my config/initializers/setup_mail.rb
Am using Heroku and Sendgrid and have installed the plug-in.
Did I need to install the 'mail' gem first, the documentation doesn't mention it??
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "25",
:authentication => :plain
:user_name => "apxxxxx#heroku.com",
:password => "9XXXXXXXXX",
:domain => "www.myapp.com",
}
I know what the issue is now - there is no comma after the user-name and password entries!