From 8b683871996645847b989adf4d528eacc064b1e3 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Wed, 19 Sep 2012 15:09:08 +0800 Subject: [PATCH] fix share loading failed --- app/controllers/application_controller.rb | 4 +++- vendor/built_in_modules/announcement/app/models/bulletin.rb | 4 ++++ vendor/built_in_modules/news/app/models/news_bulletin.rb | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 74274eebf..49e7604da 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -114,7 +114,9 @@ class ApplicationController < ActionController::Base object_class = params[:model].classify.constantize @object = object_class.find(params[:id]) module_app = ModuleApp.first(:conditions => {:key => params[:key]}) - @item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + @item = @object.share_item + #@item = Item.where(module_app_id: module_app.id).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first + #binding.pry @orig_url = "http://#{request.host_with_port}/#{@item.path}?id=#{@object.id}" render 'shared/render_share', :layout => false end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 7fbd51d86..d79864bec 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -81,6 +81,10 @@ class Bulletin integer :view_count string :bulletin_category_id end + + def share_item + Item.first(conditions:{name: 'announcement'}) + end def proc_check(check,not_pass_info = "") self.is_checked = true diff --git a/vendor/built_in_modules/news/app/models/news_bulletin.rb b/vendor/built_in_modules/news/app/models/news_bulletin.rb index 163705f6c..e00c3e9bd 100644 --- a/vendor/built_in_modules/news/app/models/news_bulletin.rb +++ b/vendor/built_in_modules/news/app/models/news_bulletin.rb @@ -16,6 +16,7 @@ class NewsBulletin + #scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false) is_impressionable :counter_cache => { :column_name => :view_count } @@ -140,6 +141,9 @@ class NewsBulletin # def s_text_zh_tw # Nokogiri::HTML(self.text.zh_tw).text # end + def share_item + Item.first(conditions:{name: 'news'}) + end def self.widget_datas( category_id = nil )