Class: Nivo::Slide
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Nivo::Slide
- Includes:
- ManageSlides
- Defined in:
- app/models/nivo/slide.rb
Constant Summary collapse
Class Method Summary collapse
-
.page(search) ⇒ Object
Find for admin index.
-
.rotate ⇒ Object
Find for slideshow.
-
.search(search) ⇒ Object
currently used in self.page.
Instance Method Summary collapse
-
#image_options ⇒ Object
html options for the slide image_tag.
-
#save_image_dimensions ⇒ Object
Save the image dimensions only when a new photo is uploaded.
Class Method Details
.page(search) ⇒ Object
Find for admin index
48 49 50 51 52 53 54 |
# File 'app/models/nivo/slide.rb', line 48 def self.page(search) if defined?(Dust::Application) (:manage).search(search).order("position") else search(search).order("position") end end |
.rotate ⇒ Object
Find for slideshow
41 42 43 |
# File 'app/models/nivo/slide.rb', line 41 def self.rotate where("active = ?", true).order("position") end |
.search(search) ⇒ Object
currently used in self.page
59 60 61 62 63 64 65 |
# File 'app/models/nivo/slide.rb', line 59 def self.search(search) if search where("caption LIKE ?", "%#{search}%") else scoped end end |
Instance Method Details
#image_options ⇒ Object
html options for the slide image_tag
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/nivo/slide.rb', line 26 def if height.blank? save_image_dimensions end = { :height => height, :width => width, :class => "slide", :title => ( if Nivo::Config.file['caption'] == true) } end |
#save_image_dimensions ⇒ Object
Save the image dimensions only when a new photo is uploaded
after_post_process :save_image_dimensions
16 17 18 19 20 21 |
# File 'app/models/nivo/slide.rb', line 16 def save_image_dimensions geo = Paperclip::Geometry.from_file(image.url(:slide)) self.width = geo.width self.height = geo.height self.save end |