Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 32 lines (23 sloc) 0.762 kb
349920a @rapind Simplified. Completely removed public facing content like portfolio a…
authored
1 class Photo < ActiveRecord::Base
2
3 # ****
4 # Associations
61beb7f @rapind changed naming of private galleries and added pages.
authored
5 belongs_to :private_gallery, :counter_cache => true
594410b @rapind admin views for galleries and pages
authored
6 belongs_to :gallery, :counter_cache => true
349920a @rapind Simplified. Completely removed public facing content like portfolio a…
authored
7
835a746 @rapind swapped carrierwave for dragonfly image resizing on the fly
authored
8 # Photo attachment
9 image_accessor :photo
10
349920a @rapind Simplified. Completely removed public facing content like portfolio a…
authored
11 # ****
12 # Validations
6c5f7e1 @rapind Switched to the latest blueprint styles
authored
13 validates :name, :presence => true, :length => { :maximum => 100 }
835a746 @rapind swapped carrierwave for dragonfly image resizing on the fly
authored
14 validates :photo, :presence => true
15
349920a @rapind Simplified. Completely removed public facing content like portfolio a…
authored
16 # ****
17 # Mass-assignment protection
594410b @rapind admin views for galleries and pages
authored
18 attr_accessible :private_gallery_id, :gallery_id, :name, :photo, :photo_cache
349920a @rapind Simplified. Completely removed public facing content like portfolio a…
authored
19
835a746 @rapind swapped carrierwave for dragonfly image resizing on the fly
authored
20 # ****
21 # Callbacks
6c5f7e1 @rapind Switched to the latest blueprint styles
authored
22 before_validation :set_name
349920a @rapind Simplified. Completely removed public facing content like portfolio a…
authored
23
24 private #----
25
6c5f7e1 @rapind Switched to the latest blueprint styles
authored
26 # If no name has been set, use the image's file name but spruce it up a little.
27 def set_name
4eb3124 @rapind added more seed data and cleaned up what we have
authored
28 self.name = photo.name[0, photo.name.rindex('.')].humanize.titleize if name.blank? and !photo.name.blank?
349920a @rapind Simplified. Completely removed public facing content like portfolio a…
authored
29 end
30
31 end
Something went wrong with that request. Please try again.