diff options
author | Philip Arndt <git@p.arndt.io> | 2015-03-05 11:52:10 +1300 |
---|---|---|
committer | Philip Arndt <git@p.arndt.io> | 2015-03-05 12:38:47 +1300 |
commit | b4064c760b80c99850527d50984cc6e611168a05 (patch) | |
tree | 69ac21bb3dc134bf8934ad4f347e47187f88d7c5 /app/models | |
parent | dff7379738dd1318783dd3135a59a480d3f1432f (diff) | |
download | refinerycms-blog-b4064c760b80c99850527d50984cc6e611168a05.tar.gz refinerycms-blog-b4064c760b80c99850527d50984cc6e611168a05.tar.bz2 refinerycms-blog-b4064c760b80c99850527d50984cc6e611168a05.zip |
Fixed test failures relating to not finding the title.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/refinery/blog/category.rb | 4 | ||||
-rw-r--r-- | app/models/refinery/blog/post.rb | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/app/models/refinery/blog/category.rb b/app/models/refinery/blog/category.rb index 5cf4ea5..ca3824e 100644 --- a/app/models/refinery/blog/category.rb +++ b/app/models/refinery/blog/category.rb @@ -12,6 +12,10 @@ module Refinery validates :title, :presence => true, :uniqueness => true + def self.by_title(title) + joins(:translations).find_by(title: title) + end + def self.translated with_translations(::Globalize.locale) end diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb index f80a939..c64c8f2 100644 --- a/app/models/refinery/blog/post.rb +++ b/app/models/refinery/blog/post.rb @@ -78,7 +78,7 @@ module Refinery def find_by_slug_or_id(slug_or_id) if slug_or_id.friendly_id? - find_by_slug(slug_or_id) + friendly.find(slug_or_id) else find(slug_or_id) end @@ -92,6 +92,10 @@ module Refinery newest_first.where(:published_at => date.beginning_of_year..date.end_of_year).with_globalize end + def by_title(title) + joins(:translations).find_by(:title => title) + end + def newest_first order("published_at DESC") end |