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
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.js { render 'toggle_enable' }
format.xml { head :ok }

View File

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