Added scope to pages model

New scope to use when listing pages to show only the ones with current locale.
This commit is contained in:
María Checa
2017-07-02 14:54:11 +02:00
parent f3b8d70d12
commit ed7b7f0361
2 changed files with 2 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ class SiteCustomization::Page < ActiveRecord::Base
scope :published, -> { where(status: 'published').order('id DESC') } scope :published, -> { where(status: 'published').order('id DESC') }
scope :with_more_info_flag, -> { where(status: 'published', more_info_flag: true).order('id ASC') } scope :with_more_info_flag, -> { where(status: 'published', more_info_flag: true).order('id ASC') }
scope :with_same_locale, -> { where(locale: I18n.locale).order('id ASC') }
def url def url
"/#{slug}" "/#{slug}"

View File

@@ -3,7 +3,7 @@
<ul class="features"> <ul class="features">
<li><%= link_to t("pages.more_info.other.how_to_use", org_name: setting['org_name']), how_to_use_path %></li> <li><%= link_to t("pages.more_info.other.how_to_use", org_name: setting['org_name']), how_to_use_path %></li>
<% SiteCustomization::Page.with_more_info_flag.each do |custom_page| %> <% SiteCustomization::Page.with_more_info_flag.with_same_locale.each do |custom_page| %>
<li><%= link_to custom_page.title, page_path(custom_page.slug) %></li> <li><%= link_to custom_page.title, page_path(custom_page.slug) %></li>
<% end %> <% end %>
</ul> </ul>