From 36ddbf68e0bd67a92eb195b5585378228243a9d2 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 29 Oct 2013 14:39:23 +0800 Subject: [PATCH] Fix menu_enabled_for --- app/controllers/admin/links_controller.rb | 2 +- app/controllers/admin/pages_controller.rb | 2 +- app/models/item.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index 923435ca..99d8dca7 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -43,7 +43,7 @@ class Admin::LinksController < Admin::ItemsController m = {} m["public"] = link.is_published ? 1 : 0 m["link"] = @site_valid_locales.inject([]) do |result, locale| - result << [locale, (link.enabled_for && link.enabled_for.include?(locale)) ? 1 : 0, (link.menu_enabled_for && link.menu_enabled_for[locale]) ? 1 :0] + result << [locale, (link.enabled_for && link.enabled_for.include?(locale)) ? 1 : 0, (link.menu_enabled_for && link.menu_enabled_for[locale].eql?("true")) ? 1 :0] end render json: JSON.pretty_generate(m) rescue diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index b08f8916..320b8e9a 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -64,7 +64,7 @@ class Admin::PagesController < Admin::ItemsController m["tags"] = page.tag.present? ? [0, page.tag.map{|c| c.to_s}] : [1] m["public"] = page.is_published ? 1 : 0 m["link"] = @site_valid_locales.inject([]) do |link, locale| - link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale]) ? 1 :0] + link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale].eql?('true')) ? 1 :0] end m["count"] = page.frontend_data_count render json: JSON.pretty_generate({design: design, module: m}) diff --git a/app/models/item.rb b/app/models/item.rb index ee2653e8..b9ee2da7 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -38,7 +38,7 @@ class Item a = [] if objects objects.each do |object| - a << object if object.menu_enabled_for.nil? ? true : object.menu_enabled_for.include?(I18n.locale.to_s) + a << object if object.menu_enabled_for.nil? ? true : object.menu_enabled_for[I18n.locale.to_s].eql?("true") end end a