Created
December 13, 2008 16:31
-
-
Save karmi/35492 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
| == Usage | |
| Declare the association in your ActiveRecord model: | |
| picturable_with_flickr | |
| You can then attach/access/destroy your pictures (assuming there's a model +Book+ in your application): | |
| Picturable.search( :text => 'My cute kitten' ) | |
| => #<Flickr::Photos::PhotoResponse:0x300dc5c ... photos[#<Flickr::Photos::Photo:0x2fe6a30 ... @id="1234567890", ... | |
| book = Books.first | |
| book.pictures.create :flickr_id => '1234567890' | |
| book.pictures.first | |
| => #<Picturable id: 1, description: "My cute kitten" ... | |
| book.pictures.first.url | |
| => "/images/pictures/books/1/1234567890_t.jpg" | |
| book.pictures.first.local_url(:square) | |
| => "/path/to/your/app/public/images/pictures/books/1/1234567890_s.jpg" | |
| book.pictures.first.url(:large) | |
| => "http://farm4.static.flickr.com/1234/0000000000_1234567890_o.jpg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment