Skip to content

Instantly share code, notes, and snippets.

@rrichards
Created May 25, 2010 23:03
Show Gist options
  • Save rrichards/413802 to your computer and use it in GitHub Desktop.
Save rrichards/413802 to your computer and use it in GitHub Desktop.
class Guide < ActiveRecord::Base
has_many :textboxes
accepts_nested_attributes_for :textboxes, :allow_destroy => true
has_attached_file :guide_image,
:styles => {:hero => "765x307!",
:smaller_hero => "674x200!",
:admin_size => "150x60!"
},
:storage => :s3,
:s3_credentials =>"#{RAILS_ROOT}/config/paperclip_s3.yml",
:path => ":attachment/:id/:style.:extension"
def self.find_by_guide_type(type)
Guide.find(:first, :conditions => ['guide_type = ?', type])
end
def hero_image
self.guide_image
end
def self.tour_guide
find(:first, :conditions => ['guide_type = ?', "tour"])
end
def self.cruise_guide
find(:first, :conditions => ['guide_type = ?', "cruise"])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment