This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The example below will easily get screwed up when your statements fails in the middle of migrations, i.e., fail after the line 9. | |
#It will require manual fix to recover your table to healthy state. | |
#MySQL support does not support rollbacking DDL statements (Postgres does it though). | |
class UpdateUsers < ActiveRecord::Migration | |
def change | |
add_column(:users, :type, :string) | |
remove_column(:users, :first_name) | |
remove_column(:users, :last_name) | |
rename_column(:users, :dob, :birth_date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
rake = File.split($0).last == 'rake' | |
if rake | |
begin | |
STDOUT.puts "MySQL root Password:" | |
password = STDIN.gets.strip.downcase | |
end until password.length > 0 | |
end | |
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person < ActiveRecord::Base | |
scope :matches, lambda {|conditions| | |
where conditions.map {|key, value| | |
if value.is_a? Array | |
value.map {|v| arel_table[key].matches("%#{v}%")} | |
else | |
arel_table[key].matches("%#{value}%") | |
end | |
}.flatten.inject(:or) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Paperclip::Attachment.default_options.update( | |
{ | |
:path => ":class/:attachment/:hash/:style.:extension", | |
:storage => :fog, | |
:fog_credentials => { | |
:provider => 'OpenStack', | |
:openstack_username => 'user', | |
:openstack_api_key => 'password', | |
:openstack_auth_url => 'auth_url', | |
}, |