Skip to content

Instantly share code, notes, and snippets.

@Boztown
Last active January 2, 2016 00:38
Show Gist options
  • Save Boztown/8224539 to your computer and use it in GitHub Desktop.
Save Boztown/8224539 to your computer and use it in GitHub Desktop.
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
rails generate scaffold Idea name:string title:string content:text
class CreateIdeas < ActiveRecord::Migration
def change
create_table :ideas do |t|
t.string :name
t.string :title
t.text :content
t.timestamps
end
end
end
idea = Idea.new(:name => 'HaveADrink', :title => 'Have A Drink', :content => 'Just go and have a drink')
1.9.3p125 :002 > idea
=> <Idea id: nil, name: "HaveADrink", title: "Have A Drink", content: "Just go and have a drink", created_at: nil, updated_at: nil>
<Idea id: nil, name: "HaveADrink", title: "Have A Drink", content: "Just go and have a drink", created_at: nil, updated_at: nil>
1.9.3p125 :003 > idea.save
(0.1ms) begin transaction
SQL (182.3ms) INSERT INTO "ideas" ("content", "created_at", "name", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?) [["content", "Just go and have a drink"], ["created_at", Tue, 24 Apr 2012 23:16:26 UTC +00:00], ["name", "HaveADrink"], ["title", "Have A Drink"], ["updated_at", Tue, 24 Apr 2012 23:16:26 UTC +00:00], ["user_id", nil]]
(20.1ms) commit transaction
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment