Class: Blogg::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Blogg::Post
- Extended by:
- FriendlyId
- Defined in:
- app/models/blogg/post.rb
Instance Method Summary collapse
- #is_article? ⇒ Boolean
- #is_static? ⇒ Boolean
- #next ⇒ Object
-
#normalize_friendly_id(value) ⇒ Object
Override FriendlyId method to transliterate slug with Babosa gem.
- #prev ⇒ Object
Instance Method Details
#is_article? ⇒ Boolean
33 34 35 |
# File 'app/models/blogg/post.rb', line 33 def is_article? !static end |
#is_static? ⇒ Boolean
29 30 31 |
# File 'app/models/blogg/post.rb', line 29 def is_static? static end |
#next ⇒ Object
37 38 39 |
# File 'app/models/blogg/post.rb', line 37 def next self.class.articles.where("id > ?", id).first end |
#normalize_friendly_id(value) ⇒ Object
Override FriendlyId method to transliterate slug with Babosa gem
20 21 22 23 24 25 26 27 |
# File 'app/models/blogg/post.rb', line 20 def normalize_friendly_id(value) case I18n.locale when :ru, :uk value.to_s.to_slug.normalize(transliterations: :russian).to_s else value.to_s.to_slug.normalize.to_s end end |
#prev ⇒ Object
41 42 43 |
# File 'app/models/blogg/post.rb', line 41 def prev self.class.articles.where("id < ?", id).last end |