Fix for Tags

This commit is contained in:
saurabhbhatia 2014-01-03 14:53:13 +08:00
parent d90351b82c
commit f3e3d702a4
2 changed files with 10 additions and 10 deletions

View File

@ -124,8 +124,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
delete_out_invalid_date_from_params delete_out_invalid_date_from_params
respond_to do |format| respond_to do |format|
if @bulletin.update_attributes(params[:bulletin]) if @bulletin.update_attributes(params[:bulletin])
@bulletin.get_bulletin_tags
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) }
format.js { render 'toggle_enable' } format.js { render 'toggle_enable' }
format.xml { head :ok } format.xml { head :ok }

View File

@ -38,7 +38,7 @@ class Bulletin
accepts_nested_attributes_for :bulletin_links, :allow_destroy => true accepts_nested_attributes_for :bulletin_links, :allow_destroy => true
validates :title, :at_least_one => true validates :title, :at_least_one => true
after_save :get_bulletin_tags # after_save :get_bulletin_tags
def to_indexed_json def to_indexed_json
self.to_json self.to_json
@ -68,13 +68,12 @@ class Bulletin
end end
def get_bulletin_tags def get_bulletin_tags
if self.changed? @tags = self.tags.collect{|t| t.id.to_s}.uniq
tag = [] tag = []
tag << self.tags.map{|t| t.id.to_s}.uniq tag << @tags
# Rails.logger.info"@@@@@@@@@@@@@@@@"+tag.inspect self.tagged_ids << @tags
self.tagged_ids = tag tags = self.tagged_ids.delete(tag.first)
# self.upsert save
end
end end
def share_item def share_item