Created
July 4, 2010 15:28
-
-
Save rrouse/463524 to your computer and use it in GitHub Desktop.
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
padrino g project dniftest -d activerecord -b | |
create | |
create config/apps.rb | |
create config/boot.rb | |
create config.ru | |
create public/favicon.ico | |
create app | |
create app/app.rb | |
create app/controllers | |
create app/helpers | |
create .components | |
create Gemfile | |
Applying 'activerecord' (orm)... | |
apply orms/activerecord | |
inject Gemfile | |
inject Gemfile | |
create config/database.rb | |
create app/models | |
Skipping generator for test component... | |
Skipping generator for mock component... | |
Skipping generator for script component... | |
Applying 'haml' (renderer)... | |
apply renderers/haml | |
inject Gemfile | |
Skipping generator for stylesheet component... | |
Bundling application dependencies using bundler... | |
run bundle install from "./" | |
Project 'dniftest' has been generated and all dependencies bundled! |
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 CreateStories < ActiveRecord::Migration | |
def self.up | |
create_table :stories do |t| | |
t.string :author | |
t.string :title | |
t.text :body | |
t.datetime :published | |
t.boolean :draft | |
end | |
end | |
def self.down | |
drop_table :stories | |
end | |
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
rake dnif:configure | |
rake dnif:index | |
rake dnif:start | |
##Search Results | |
padrino console | |
=> Loading development console (Padrino v.0.9.14) | |
=> Loading Application Dniftest | |
ruby-1.9.2-rc1 > Story.search("teapot") | |
DEBUG - [04/Jul/2010 14:17:52] "Story Load (0.3ms) SELECT * FROM "stories" WHERE ("stories"."id" IN (1)) " | |
=> [#<Story id: 1, author: "Robert Rouse", title: "Test Story", body: "I am a teapot, short and stout", published: "2010-07-04 10:39:49", draft: false>] | |
ruby-1.9.2-rc1 > Story.search("Story") | |
DEBUG - [04/Jul/2010 14:18:07] "Story Load (0.2ms) SELECT * FROM "stories" WHERE ("stories"."id" IN (1)) " | |
=> [#<Story id: 1, author: "Robert Rouse", title: "Test Story", body: "I am a teapot, short and stout", published: "2010-07-04 10:39:49", draft: false>] |
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
source :rubygems | |
# Project requirements | |
gem 'rake' | |
gem 'rack-flash' | |
gem 'thin' # or mongrel | |
# Component requirements | |
gem 'haml' | |
gem 'activerecord', :require => "active_record" | |
gem 'sqlite3-ruby', :require => "sqlite3" | |
gem 'dnif' | |
# Test requirements | |
# Padrino | |
gem 'padrino', "0.9.14" |
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
padrino g model Story | |
=> Located unlocked Gemfile for development | |
apply orms/activerecord | |
create app/models/story.rb | |
create db/migrate/001_create_stories.rb |
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
padrino rake ar:migrate | |
=> Executing Rake ar:migrate ... | |
== CreateStories: migrating ================================================== | |
-- create_table("stories", {}) | |
-> 0.0011s | |
== CreateStories: migrated (0.0015s) ========================================= |
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
gem install padrino | |
gem install dnif --pre |
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 'dnif/tasks' | |
Dnif.models_path = "./app/models" | |
task :environment do | |
require './config/boot' | |
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
ruby-1.9.2-rc1 > s = Story.new | |
=> #<Story id: nil, author: nil, title: nil, body: nil, published: nil, draft: nil> | |
ruby-1.9.2-rc1 > s.author = "Robert Rouse" | |
=> "Robert Rouse" | |
ruby-1.9.2-rc1 > s.title = "Test Story" | |
=> "Test Story" | |
ruby-1.9.2-rc1 > s.body = "I am a teapot, short and stout" | |
=> "I am a teapot, short and stout" | |
ruby-1.9.2-rc1 > s.published = Time.now | |
=> 2010-07-04 10:39:49 -0500 | |
ruby-1.9.2-rc1 > s.draft = false | |
=> false | |
ruby-1.9.2-rc1 > s.save | |
DEBUG - [04/Jul/2010 10:40:00] "Story Create (0.4ms) INSERT INTO "stories" ("author", "title", "body", "published", "draft") VALUES('Robert Rouse', 'Test Story', 'I am a teapot, short and stout', '2010-07-04 10:39:49', 'f')" | |
=> true | |
ruby-1.9.2-rc1 > s = Story.new | |
=> #<Story id: nil, author: nil, title: nil, body: nil, published: nil, draft: nil> | |
ruby-1.9.2-rc1 > s.author = "Robert Rouse" | |
=> "Robert Rouse" | |
ruby-1.9.2-rc1 > s.title = "Test Story 2" | |
=> "Test Story 2" | |
ruby-1.9.2-rc1 > s.body = "Bozz and Witty avoid the Test store" | |
=> "Bozz and Witty avoid the Test store" | |
ruby-1.9.2-rc1 > s.published = Time.now | |
=> 2010-07-04 10:41:09 -0500 | |
ruby-1.9.2-rc1 > s.draft = true | |
=> true | |
ruby-1.9.2-rc1 > s.save | |
DEBUG - [04/Jul/2010 10:41:15] "Story Create (0.3ms) INSERT INTO "stories" ("author", "title", "body", "published", "draft") VALUES('Robert Rouse', 'Test Story 2', 'Bozz and Witty avoid the Test store', '2010-07-04 10:41:09', 't')" | |
=> true |
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 Story < ActiveRecord::Base | |
define_index do | |
field :title | |
field :body | |
where ["draft = ?", false] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment