I added add_column :microposts, :type, :string to one of my db migrations (not the most recent one if that matters). and also ran rake db:reset. So I have definitely made changes. But now if I run rake db:migrate or bundle exec rake db:migrate, it doesn't output anything. If I run trace...
alex#alex-ThinkPad-T410:~/rails_projects/final2$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** 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
You wrote:
I added add_column :microposts, :type, :string to one of my db
migrations (not the most recent one if that matters).
This suspiciously sounds, as if you just added the text into the migration file. That won't work. The migration state machine doesnt notice changes in the actual text files. Please check
rake db:migrate:status
You should instead create a new migration
rails g migration AddTypeToMicropost type:string
and then run rake again
Related
None of my assets, such as images, javascripts, and styling features are showing up when I run the following command:
RAILS_ENV=production rails s
Then I go to http://localhost:3000 and the application comes up, but has no styling at all.
I did precompile the assets:
➜ myapp git:(master) ✗ bundle exec rake assets:precompile --trace
Invoke assets:precompile (first_time)
Execute assets:precompile
/Users/me/.rvm/rubies/ruby-1.9.3-p545/bin/ruby /Users/me/.rvm/gems/ruby-1.9.3-p545#myapp/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
Invoke assets:precompile:all (first_time)
Execute assets:precompile:all
Invoke assets:precompile:primary (first_time)
Invoke assets:environment (first_time)
Execute assets:environment
Invoke environment (first_time)
Execute environment
Invoke tmp:cache:clear (first_time)
Execute tmp:cache:clear
Execute assets:precompile:primary
Invoke assets:precompile:nondigest (first_time)
Invoke assets:environment (first_time)
Execute assets:environment
Invoke environment (first_time)
Execute environment
Invoke tmp:cache:clear (first_time)
Execute tmp:cache:clear
Execute assets:precompile:nondigest
This works just fine in Safari, can't figure out why Chrome won't load the stuff. I cleared out the browser cache also.
In config/environments/production.rb, make sure your application is configured to serve static assets:
config.serve_static_assets = true
By default, Rails assumes that your static assets will be served elsewhere (e.g. Apache, Nginx, etc.)
I've been cap deploying my app all throughout it development, and this last time I tried to deploy it, it didn't work. Here's what happened:
* executing `deploy:assets:precompile'
* executing "cd /var/www/oneteam/releases/20121006153136 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["electricsasquatch.com"]
[electricsasquatch.com] executing command
** [out :: electricsasquatch.com] rake aborted!
** [out :: electricsasquatch.com] uninitialized constant OneTeam::Application::FactoryGirl
** [out :: electricsasquatch.com]
** [out :: electricsasquatch.com] (See full trace by running task with --trace)
It looks like it failed on the deploy:assets:precompile command. I don't get why that command would have tried to do anything with FactoryGirl, though. Any ideas?
It is not that something is wrong with deploy:assets:precompile task, but something is wrong with rake task that is using FactoryGirl. Even if you place a syntax error let us say in lib/tasks/first.rake and you execute task from lib/tasks/second.rake for instance rake second the rake will scream with rake aborted!. Even rake -T will not work. So there is rake task that is trying to use FactoryGirl but FactoryGirl is not included.
I had this in config/application.rb:
FactoryGirl.define do
sequence(:random_string) { |s| ('a'..'z').to_a.shuffle[0, 30].join }
end
I changed it to this:
if Rails.env != "production"
FactoryGirl.define do
sequence(:random_string) { |s| ('a'..'z').to_a.shuffle[0, 30].join }
end
end
The problem went away.
I'm trying to have success on running the task rake assets:precompile but I have the following error
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
stack level too deep
(in .../app/assets/stylesheets/admin/scaffolds.css.scss)
.....rvm/gems/ruby-1.9.2-p320#global/gems/rake-0.9.2.2/lib/rake/task.rb:162
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/Users/diogui/.rvm/rubies/ruby-1.9.2-p320/...]
.....rvm/gems/ruby-1.9.2-p320#global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
....rvm/gems/ruby-1.9.2-p320#global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
....rvm/gems/ruby-1.9.2-p320#global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
....rvm/gems/ruby-1.9.2-p320#global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
....rvm/gems/ruby-1.9.2-p320#global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:80:in `ruby'
.....rvm/gems/ruby-1.9.2-p320#global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
.....rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.1.1/lib/sprockets/assets.rake:9:in `ruby_rake_task'
....rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.1.1/lib/sprockets/assets.rake:17:in ` invoke_or_reboot_rake_task'
In my production.rb I have
config.serve_static_assets = false
config.assets.enabled = true
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
Yes I have Sass 3.1.4
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
Does anybody have an idea what is the problem ? Or what am I missing ? Thanks :)
It turns out this is a documented issue with the sass-rails gem: https://github.com/rails/sass-rails/issues/78
It can apparently be solved by downgrading the sass-rails gem to 3.1.4 (if you're on Rails 3.1) or upgrading to 3.2.5 (if you're on Rails 3.2): "rake aborted! stack level too deep" while deploying to Heroku
This worked for me :)
Changing the ruby version to 2.3.0 did the trick.
This one saved my day.
When I run rake db:migrate, I don't get a response.
Doing a trace, I get the following but I am not sure how to interpret it:
$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
I am running rails 3.0.10.
As coreyword suggested, perhaps there are no new migrations to run.
The rake db:migrate command will exit silently when there's nothing (new) to do.
So I'm converting my Admin mailers to use Resque and execute in the background.
When I ran:
rake resque:work QUEUE='*' --trace
I get this:
$ rake resque:work QUEUE='*' --trace (in /my/directory)
** Invoke resque:work (first_time)
** Invoke resque:preload (first_time)
** Execute resque:preload rake aborted! undefined method `paginates_per' for #<Class:0x000000045ba1b8>
which traces back to my Micropost model that default to 10 micropost per page using kaminari's dsl method paginates_per:
class Micropost < ActiveRecord::Base
.
.
.
paginates_per 10
How do I get rake to stop puking without moving the DSL method?