Created
January 27, 2015 16:45
-
-
Save stungeye/80ff91b90b8e4a1b4c56 to your computer and use it in GitHub Desktop.
Simple AR without Rails Example
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
require 'active_record' | |
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => 'db/development.sqlite3' | |
class Customer < ActiveRecord::Base | |
# Associated with the customers. | |
end | |
# SELECT * FROM customers ORDER BY id ASC LIMIT 1 | |
first_customer = Customer.first | |
puts "#{first_customer.name} lives in the city of #{first_customer.city}." | |
# SELECT COUNT(*) FROM customers | |
customer_count = Customer.count | |
puts "My customers table contains #{customer_count} customers." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment