diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-25 17:50:55 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-25 17:50:55 +0200 |
| commit | 26030c71c7b300c30367222f263d74b8d2142ecf (patch) | |
| tree | cd05051e7bc4e9252b0084f98b7c3df485c8c601 /app/models/page.rb | |
| parent | 7f26a8202556db3a584f1360950a671d2a60a1ea (diff) | |
Rails 5.2 application fixes
- Rename before_filter → before_action across all controllers
- Fix string conditions in validators to lambda syntax (node.rb)
- Fix publish_draft!: move staged slug/parent logic outside draft guard,
use move_to_child_of for parent changes, add nil guard for no-op calls
- Fix update_unique_names_of_children: use parent_id traversal instead
of lft/rgt descendants (awesome_nested_set 3.x lft/rgt update bug)
- Fix unique_path to return Array instead of String
- Fix Occurrence.delete_all syntax for Rails 5
- Fix Page.find_with_outdated_translations: use includes instead of all
- Fix outdated_translations?: use find instead of splat array
Diffstat (limited to 'app/models/page.rb')
| -rw-r--r-- | app/models/page.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index e2cbee5..93debf8 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -83,7 +83,7 @@ class Page < ActiveRecord::Base | |||
| 83 | # outdated_translations? for more information. | 83 | # outdated_translations? for more information. |
| 84 | # Takes :locale => <locale> and :delta_time => 12.hours as options | 84 | # Takes :locale => <locale> and :delta_time => 12.hours as options |
| 85 | def self.find_with_outdated_translations options = {} | 85 | def self.find_with_outdated_translations options = {} |
| 86 | Page.all(:include => :translations).select do |page| | 86 | Page.includes(:translations).select do |page| |
| 87 | page.outdated_translations? options | 87 | page.outdated_translations? options |
| 88 | end | 88 | end |
| 89 | end | 89 | end |
| @@ -182,8 +182,8 @@ class Page < ActiveRecord::Base | |||
| 182 | 182 | ||
| 183 | translations = self.translations | 183 | translations = self.translations |
| 184 | 184 | ||
| 185 | default = *(translations.select {|x| x.locale == I18n.default_locale}) | 185 | default = translations.find {|x| x.locale.to_s == I18n.default_locale.to_s } |
| 186 | custom = *(translations.select {|x| x.locale == options[:locale]}) | 186 | custom = translations.find {|x| x.locale.to_s == options[:locale].to_s } |
| 187 | 187 | ||
| 188 | if translations.size > 1 && default && custom | 188 | if translations.size > 1 && default && custom |
| 189 | difference = (default.updated_at - custom.updated_at).to_i.abs | 189 | difference = (default.updated_at - custom.updated_at).to_i.abs |
