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.
I have some code that accesses an MLS listing service and downloads pictures into AWS. I am getting the error on MLS login. I'm on ruby 2.2.2p95 and rails 3.2.22.
My code:
AWS::S3::Base.establish_connection!(
:access_key_id => ACCESS_KEY_ID,
:secret_access_key => SECRET_ACCESS_KEY
)
puts 'connected to AWS'
client = Rets::Client.new({
login_url: LOGIN_URL,
username: LOGIN,
password: PASSWORD,
version: VERSION
})
begin
client.login
# rescue => e
# puts 'Error: ' + e.message
# exit!
end
The error:
➜ LiveByTransit git:(master) ✗ rake update_pics --trace
** Invoke update_pics (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute update_pics
66
connected to AWS
rake aborted!
TypeError: no implicit conversion of nil into String
/home/nitrous/code/LiveByTransit/.bundle/gems/nokogiri-1.6.6.3/lib/nokogiri/xml/document.rb:55:in `read_memory'
/home/nitrous/code/LiveByTransit/.bundle/gems/nokogiri-1.6.6.3/lib/nokogiri/xml/document.rb:55:in `parse'
/home/nitrous/code/LiveByTransit/.bundle/gems/nokogiri-1.6.6.3/lib/nokogiri/xml.rb:64:in `parse'
/home/nitrous/code/LiveByTransit/.bundle/gems/rets-0.9.0/lib/rets/parser/error_checker.rb:17:in `check'
/home/nitrous/code/LiveByTransit/.bundle/gems/rets-0.9.0/lib/rets/http_client.rb:20:in `http_get'
/home/nitrous/code/LiveByTransit/.bundle/gems/rets-0.9.0/lib/rets/client.rb:344:in `http_get'
/home/nitrous/code/LiveByTransit/.bundle/gems/rets-0.9.0/lib/rets/client.rb:63:in `login'
/home/nitrous/code/LiveByTransit/lib/tasks/update_pics.rake:45:in `block in <top (required)>'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
.bundle/binstubs/rake:16:in `load'
.bundle/binstubs/rake:16:in `<main>'
Tasks: TOP => update_pics
➜ LiveByTransit git:(master) ✗ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
➜ LiveByTransit git:(master) ✗ rails -v
Rails 3.2.22
In my code above, you'll see I commented out the error rescue. If I comment back in, the error looks like this:
➜ LiveByTransit git:(master) ✗ rake update_pics --trace
** Invoke update_pics (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute update_pics
66
connected to AWS
Error: no implicit conversion of nil into String
➜ LiveByTransit git:(master) ✗
I've tried this suggestion with no change.
Ok, so I know I am playing with the big boys and girls here messing with front and backend MVC (even though bbone isn't exactly MVC) for an application, but this is the first real robust application I have ever worked on, and unfortunately being in the academics realm, support isn't there, esp for more cutting edge, so I am thankful in advance.
I have some errors when trying to deploy to Heroku with a Rails (3.2.2) app, and the asset pipeline has been causing problems all the time. Since I am using BBone for the front end, and the [single]page[app] needs to know the paths to images and sounds on load, I had to use this gist to attach the image paths to the App.assets to pass to the application.js file for require.js to start the application being built on the front end.
The problem appears to be that Devise wants: config.assets.initialize_on_precompile = false while require wants: config.assets.initialize_on_precompile = true and Heroku wants in the production.rb file to be: config.assets.compile = true.
The error I am getting is in the gist file assets.js.erb where the call is made to the DB to get all the songs in the Song model, second to last line
App = {};
App.assets = {
// Returns an object containing all of asset pipeline's image paths.
//
// Sample:
//
// {
// avatars/missing_avatar.png: "/assets/avatars/missing_avatar.png"
// chosen-sprite.png: "/assets/chosen-sprite.png"
// circle_green.png: "/assets/circle_green.png"
// circle_orange.png: "/assets/circle_orange.png"
// circle_red.png: "/assets/circle_red.png"
// circle_yellow.png: "/assets/circle_yellow.png"
// document.png: "/assets/document.png"
// }
//
// This hash is because Rails' Asset Pipeline bundles the routes to files
// per user session, then hands that to the user's session browser, for security.
// So we create in Ruby (erb = embedded ruby) a hash of the images to be accessed
// in the JS.
images: {
<% AssetsUtil.images.each do |img| %>
"<%= img %>" : "<%= asset_path(img) %>",
<% end %>
},
// Return a formatted URL for an asset.
//
// Sample:
//
// "/assets/document/png."
//
path: function(name) {
// If the file is in our images object, pull the path from there.
if (this.images && this.images[name]) {
return this.images[name];
}
// Otherwise, create a generic asset path.
return '/assets/' + name;
}
};
// Currently this is ALL the songs in the DB, not just the current_user 's songs
App.songs = {
songs: <%= Song.all.to_json.html_safe %>
};
The full trace error trying to rake assets:precompile as suggested todo before deploying to Heroku is:
** Invoke assets:precompile (first_time)
** Invoke requirejs:precompile:external (first_time)
** Invoke requirejs:test_node (first_time)
** Execute requirejs:test_node
** Execute requirejs:precompile:external
/Users/me/.rvm/rubies/ruby-1.9.3-p362/bin/ruby /Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake requirejs:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke requirejs:precompile:all (first_time)
** Invoke requirejs:precompile:prepare_source (first_time)
** Invoke requirejs:setup (first_time)
** Invoke assets:environment (first_time)
** Invoke requirejs:precompile:disable_js_compressor (first_time)
** Execute requirejs:precompile:disable_js_compressor
** Execute assets:environment
** Execute requirejs:setup
** Invoke requirejs:clean (first_time)
** Invoke requirejs:setup
** Execute requirejs:clean
** Execute requirejs:precompile:prepare_source
rake aborted!
uninitialized constant Song
(in /Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb)
/Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb:48:in `block in singletonclass'
/Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb:65530:in `instance_eval'
/Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb:65530:in `singletonclass'
/Users/me/dev/SoundOfFractions/app/assets/javascripts/assets.js.erb:65528:in `__tilt_70168709646800'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/tilt-1.3.4/lib/tilt/template.rb:144:in `call'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/tilt-1.3.4/lib/tilt/template.rb:144:in `evaluate'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/tilt-1.3.4/lib/tilt/template.rb:77:in `render'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/context.rb:177:in `block in evaluate'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/context.rb:174:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/context.rb:174:in `evaluate'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/processed_asset.rb:12:in `initialize'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in `new'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in `block in build_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:262:in `circular_call_protection'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:240:in `build_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in `block in build_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in `build_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in `find_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in `find_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/bundled_asset.rb:16:in `initialize'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:244:in `new'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:244:in `build_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in `block in build_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in `build_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in `find_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in `find_asset'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/requirejs-rails-0.9.1/lib/tasks/requirejs-rails_tasks.rake:94:in `block (4 levels) in <top (required)>'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:212:in `block in each_logical_path'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:200:in `block (2 levels) in each_file'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:190:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:190:in `each_entry'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:198:in `block in each_file'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:197:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:197:in `each_file'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/sprockets-2.1.3/lib/sprockets/base.rb:210:in `each_logical_path'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/requirejs-rails-0.9.1/lib/tasks/requirejs-rails_tasks.rake:92:in `block (3 levels) in <top (required)>'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `load'
/Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `<main>'
Tasks: TOP => requirejs:precompile:all => requirejs:precompile:prepare_source
rake aborted!
Command failed with status (1): [/Users/me/.rvm/rubies/ruby-1.9.3-p362...]
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils.rb:80:in `ruby'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `ruby'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/actionpack-3.2.2/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/Users/me/.rvm/gems/ruby-1.9.3-p362/gems/requirejs-rails-0.9.1/lib/tasks/requirejs-rails_tasks.rake:85:in `block (3 levels) in <top (required)>'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/Users/me/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/me/.rvm/gems/ruby-1.9.3-p362#global/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `load'
/Users/me/.rvm/gems/ruby-1.9.3-p362/bin/rake:19:in `<main>'
/Users/me/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `eval'
/Users/me/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => assets:precompile => requirejs:precompile:external
gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.2'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
gem 'railroady'
gem 'sqlite3'
# For linux support
gem 'therubyracer'
end
group :production do
gem 'pg'
gem 'thin'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'uglifier', '>= 1.0.3'
end
# gem "better_errors", ">= 0.2.0", :group => :development
# gem "binding_of_caller", ">= 0.6.8", :group => :development
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'jquery-rails'
gem 'rails-backbone'
gem "bootstrap-sass", "~> 2.3.0.0"
gem 'requirejs-rails'
gem 'ejs'
gem 'devise'
gem "better_errors", ">= 0.2.0", :group => :development
gem "binding_of_caller", ">= 0.6.8", :group => :development
gem 'color_routes'
gem 'gon'
So where should I start with my configuration to finish deployment?
Potential info:
If you watch how to make custom rake tasks from Railscasts here, the same error occurs when running the custom rake task, and Ryan explains that the task can't access the DB because the custom task needs an => :environment dependency (~4:15 in the movie) to access the User class. Since the precompile can't access the songs model, how could I provide the same or similar dependency to the application.js file?
OTHER info:
To my understanding the way the asset pipeline works is for each session, it bundles the paths (so when you type something like <%= link_to 'Sign in', new_user_path %>, rails defines those paths in the asset pipeline, and serves it to the user. Since Backbone is client side rendering, it needs to know the paths to the images and sounds after the page is handed from the rails server, and the only way to do this that I found was the gist listed above, where it bundles the "assets" to the JS, a similar approach to gem 'gon' that provides global variables to the page. I of course am plying in new grounds, and open to restructuring, but it works in dev mode, so I am trying to figure out production as well.
The Rails Environment is not available to you during heroku asset precompile. As they are made once and not refreshed again tell the next deploy. That being said. You should move your dynamic DB related calls to your views and render the data either via API calls or "bootstraping" the data by writing your Javascript ton a script tag in the dom in json. I normally have window.NAME_OF_APPLICATION.collections.SONGS so they are available to me in a global scope.
Example.
:javascript
window.lineItems = {lineItems: #{ #order.line_items.order("position").to_json( :include => :department).html_safe}, order: #{#order.to_json} }
When Backbone comes online have it call for these items. And initialize a collection for them.
#burningpony's accepted answer above is not entirely correct.
The Rails env is available during heroku asset precompile if you use the labs plugin:
https://devcenter.heroku.com/articles/labs-user-env-compile
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|
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!