Rails rake db:migrate has no effect

There’s a few reasons why your migrations won’t run, but the most common is that the system is already under the impression that all the migrations you’ve defined have already run. Each migration creates an entry in the schema_migrations table with the version column corresponding to the identifier number. If you want to force a … Read more

FactoryGirl screws up rake db:migrate process

I think you need to have factory girl definition like that in Gemfile: gem ‘factory_girl_rails’, :require => false And then you just require it in your spec_helper.rb like that: require ‘factory_girl_rails’ This is the way I’m always using this gem. You don’t need to require it in other places than spec_helper.rb. Your current desired approach … Read more

Make rake task from gem available everywhere?

For Rails3 applications, you might want to look into making a Railtie for your gem. You can do so with: lib/your_gem/railtie.rb require ‘your_gem’ require ‘rails’ module YourGem class Railtie < Rails::Railtie rake_tasks do require ‘path/to/rake.task’ end end end lib/your_gem.rb module YourGem require “lib/your_gem/railtie” if defined?(Rails) end Though, I had my share of difficulties with requiring … Read more

File.open, write and save?

If you just need to perform a simple script like creating a file, you can simply use a Ruby script without creating a rake task. # file origin.rb target = “target.rb” content = <<-RUBY puts “I’m the target!” RUBY File.open(target, “w+”) do |f| f.write(content) end And you can execute the file with $ ruby origin.rb

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)