When I run the rake:db migrate command I get an error “Uninitialized constant CreateArticles”

Be sure that your file name and class name say the same thing(except the class name is camel cased).The contents of your migration file should look something like this, simplified them a bit too: #20090106022023_create_articles.rb class CreateArticles < ActiveRecord::Migration def self.up create_table :articles do |t| t.belongs_to :user, :category t.string :title t.text :synopsis, :limit => 1000 … Read more

What is the difference between Rails.cache.clear and rake tmp:cache:clear?

The rake task only clears out files that are stored on the filesystem in “#{Rails.root}/tmp/cache”. Here’s the code for that task. namespace :cache do # desc “Clears all files and directories in tmp/cache” task :clear do FileUtils.rm_rf(Dir[‘tmp/cache/[^.]*’]) end end https://github.com/rails/rails/blob/ef5d85709d346e55827e88f53430a2cbe1e5fb9e/railties/lib/rails/tasks/tmp.rake#L25-L30 Rails.cache.clear will do different things depending on your apps setting for config.cache_store. http://guides.rubyonrails.org/caching_with_rails.html#cache-stores If you … Read more

Including rake tasks in gems

On Rails 3, you do this via Railties. Here’s the code to do it for a gem I just made: class BackupTask < Rails::Railtie rake_tasks do Dir[File.join(File.dirname(__FILE__),’tasks/*.rake’)].each { |f| load f } end end So you basically create a class that inherits from Rails::Railtie, then within that class you have a rake_tasks block that loads … Read more

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