forked from refinery/refinerycms-portfolio
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a select list to select the parent portfolio entry for a given po…
…rtfolio entry. Caveats being it can't be the entry itself and it can't be a descendant of the entry.
- Loading branch information
Showing
6 changed files
with
37 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
class PortfolioEntry < ActiveRecord::Base | ||
|
||
validates_presence_of :title | ||
|
||
# call to gems included in refinery. | ||
has_friendly_id :title, :use_slug => true, :strip_diacritics => true | ||
acts_as_tree :order => "position" | ||
|
||
has_and_belongs_to_many :images | ||
|
||
def content | ||
self.body | ||
end | ||
|
||
def content=(value) | ||
self.body = value | ||
end | ||
|
||
def image_ids=(ids) | ||
self.images.clear | ||
|
||
ids.reject{|id| id.blank? }.each do |image_id| | ||
image = Image.find(image_id.to_i) rescue nil | ||
self.images << image unless image.nil? | ||
end | ||
end | ||
|
||
|
||
def indented_title | ||
"#{"--" * self.ancestors.size} #{self.title}".chomp | ||
end | ||
|
||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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