Skip to content

Instantly share code, notes, and snippets.

@ecpplus
Last active December 10, 2015 20:18
Show Gist options
  • Select an option

  • Save ecpplus/4487179 to your computer and use it in GitHub Desktop.

Select an option

Save ecpplus/4487179 to your computer and use it in GitHub Desktop.
Rails3.2.x で github/ripple を使う。
require 'ripple/railtie'
# rails g ripple をして必要ファイルを生成すること
class Article
include Ripple::Document
property :title, String
property :body, String, presence:true
one :user
end
gem 'ripple', "~>1.0.0.beta2"
class User
include Ripple::Document
property :name, String
property :login, String, presence:true
index :login, String
many :articles
end
> u = User.create(name:'CHU', login:'chu')
=> <User:o8fmcna88jctpxghshj7j5oncr9 login="chu" name="CHU">
> u.articles < < Article.create(title:"Hello world")
=> <Article:rsfkusim2keemw62kmtwjbjzo7n title="Hello world" body=nil>
> u.save
=> true
> User.find('7MtYxfhCObVSBqPX7DlEQYA5rtY')
=> <User:o8fmcna88jctpxghshj7j5oncr9 login="chu" name="CHU">
> User.find_by_index(:login, 'chu')
=> [<User:o8fmcna88jctpxghshj7j5oncr9 login="chu" name="CHU">]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment