rails generate paperclip_database:migration getting protected method `migration_file_name’ error

Quick fix (put this in application.rb or similar in order to run the rails generate paperclip_databasee:migration command): module PaperclipDatabase module Generators class MigrationGenerator public :migration_file_name end end end There are two errors causing this error, one in paperclip and one in paperclip_database. Not sure what changes to Rails 4 caused this, but the issue is […]

foreigner foreign_key on a different column in source and target table.

In the foreigner gem, you can specify the foreign_key column on the source table by using the column option. class Cats < ActiveRecord::Migration def change create_table :cats do |t| t.integer :color_id t.integer :second_color_id t.timestamps end add_foreign_key :cats, :colors, column: :second_color_id end end But what about the target table? This can be accomplished using the primary_key […]