Class: SimpleBlog::SimplePost
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SimpleBlog::SimplePost
- Includes:
- SimpleContentManagement::ContentText
- Defined in:
- app/models/simple_blog/simple_post.rb
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
31 32 33 |
# File 'app/models/simple_blog/simple_post.rb', line 31 def destroy update_attribute :deleted, true end |
#tags_list ⇒ Object
18 19 20 |
# File 'app/models/simple_blog/simple_post.rb', line 18 def .pluck("name").join "," end |
#tags_list=(tags_list) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/models/simple_blog/simple_post.rb', line 22 def tag_names = .split %r{\s*,\s*} = SimpleBlog::SimplePostTag.where(name: tag_names).all existing_tag_names = .map &:name self. = ( + tag_names.map{ |tag_name| SimpleBlog::SimplePostTag.create(name: tag_name) unless existing_tag_names.include? tag_name }.compact) end |
#to_param ⇒ Object
14 15 16 |
# File 'app/models/simple_blog/simple_post.rb', line 14 def to_param "#{id}-#{title.parameterize}" end |