Created
August 3, 2011 16:25
-
-
Save mort/1123063 to your computer and use it in GitHub Desktop.
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
| ree-1.8.7-2011.03 :147 > k = User.first.kbadges.find_or_create_by_title(:title => 'Foo', :variant=>"collectible", :badge_type=>"newbish", :description=>"Fashion gems are fashion!", :grant_activity_date=>"2009-10-28 08:02:29 UTC") | |
| => #<Kbadge id: nil, user_id: 1, title: {:variant=>"collectible", :badge_type=>"newbish", :description=>"Fashion gems are fashion!", :title=>"Foo", :grant_activity_date=>"2009-10-28 08:02:29 UTC"}, description: nil, variant: nil, badge_type: nil, badge_count: 0, grant_activity_date: nil, created_at: nil, updated_at: nil> | |
| ree-1.8.7-2011.03 :148 > k.title | |
| => {:variant=>"collectible", :badge_type=>"newbish", :description=>"Fashion gems are fashion!", :title=>"Foo", :grant_activity_date=>"2009-10-28 08:02:29 UTC"} |
Author
Sí, solucionado con usar la sintaxis de bloque para los atributos. Gracias mil.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class Foo < ActiveRecord::Base
attr_protected :bar
validates_presence_of :bar
end
ruby-1.8.7-p334 :003 > foo = Foo.find_or_create_by_bar(:bar => "BAR", :foobar => "FOOBAR")
=> #Foo id: nil, bar: nil, foobar: "FOOBAR", created_at: nil, updated_at: nil>