Last active
December 19, 2015 07:29
-
-
Save RobinDaugherty/5919492 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
class Picture < ActiveRecord::Base | |
attr_accessible :picture, :picture_105px_width, :picture_120px_width | |
has_many :pin | |
end |
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
class Pin < ActiveRecord::Base | |
belongs_to :picture_record, class_name: Picture | |
def picture | |
picture_record || read_attribute('picture') | |
end | |
end |
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
<% if @pin.picture.respond_to?(:picture_105px_wide) && @pin.picture.picture_105px_wide.present? %> | |
<%= image_tag @pin.picture.picture_105px_wide %> | |
<% else %> | |
<%= image_tag @pin.picture %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment