This file contains hidden or 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
begin | |
ActiveRecord::Schema.define do | |
create_table :listings do |table| | |
table.column :url, :string | |
table.column :title, :string | |
table.column :authors_email, :string | |
table.column :emailed_at, :datetime | |
table.column :created_at, :datetime | |
table.column :updated_at, :datetime | |
end |
This file contains hidden or 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
require 'active_record' | |
require 'sqlite3' | |
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', | |
:database => 'db/address_book.db' | |
ActiveRecord::Base.connection.execute <<-SQL | |
-- Address book schema | |
CREATE TABLE contacts ( |
This file contains hidden or 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
Contact.joins(:addresses).includes(:addresses).where("first_name LIKE 'A%').each do |contact| | |
puts contact.address.inspect | |
end |
This file contains hidden or 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
Contact.joins(:addresses).includes(:addresses).where("first_name LIKE 'A%').each do |contact| | |
puts contact.address.inspect | |
end |
OlderNewer