From dc68f40cb47332bd15410e45c986027175b53851 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Fri, 15 Mar 2013 15:10:14 +0800 Subject: [PATCH] correct model method --- .../app/models/writing_conference.rb | 14 --------- .../app/models/writing_journal.rb | 31 ------------------- .../personal_journal/db/seeds.rb | 6 ++-- 3 files changed, 2 insertions(+), 49 deletions(-) diff --git a/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb b/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb index 090f54d1f..9e22d6c1f 100644 --- a/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb +++ b/vendor/built_in_modules/personal_conference/app/models/writing_conference.rb @@ -42,7 +42,6 @@ class WritingConference validates :paper_title, :at_least_one => true before_validation :add_http after_save :save_writing_conference_files - before_save :update_co_author validates :url, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i, :unless => Proc.new{self.url.blank?} attr_reader :author_tokens @@ -64,19 +63,6 @@ class WritingConference self.conference_co_author_ids = authors_ids end - def update_co_author - if new_record? - current_user = self.create_user_id - else - current_user = self.update_user_id - end - - self.conference_co_author_ids.each do |id| - co_author = ConferenceCoAuthor.find(id) - co_author.update_attribute(:name_id, current_user) - end - end - def self.search( category_id = nil ) if category_id.to_s.size > 0 find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title ) diff --git a/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb b/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb index 0b66a0ac3..12c7fba2f 100644 --- a/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb +++ b/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb @@ -36,8 +36,6 @@ class WritingJournal accepts_nested_attributes_for :writing_journal_files, :allow_destroy => true after_save :save_writing_journal_files before_validation :add_http - #before_save :save_co_author - before_save :update_co_author validates :paper_title, :at_least_one => true validates :url, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i, :unless => Proc.new{self.url.blank?} @@ -65,35 +63,6 @@ class WritingJournal self.journal_co_author_ids = authors_ids end - def update_co_author - if new_record? - current_user = self.create_user_id - else - current_user = self.update_user_id - end - - self.journal_co_author_ids.each do |id| - co_author = JournalCoAuthor.find(id) - co_author.update_attribute(:name_id, current_user) - end - end - # old method - #def save_co_author - # authors_list = authors.split(",").map{|n| n.strip.gsub(/\s+/," ")}.reject{|n| n.empty? } - # if new_record? - # current_user = create_user_id - # else - # current_user = update_user_id - # end - - # authors_db = JournalCoAuthor.where(:name_id => current_user).map(&:co_author) - # authors_list.delete(User.find(current_user).name) - # authors_list = authors_list.delete_if{|author| authors_db.include?author} - # authors_list.each do |author| - # JournalCoAuthor.new(:co_author => author, :name_id => current_user).save - # end - #end - def self.search( category_id = nil ) if category_id.to_s.size > 0 find(:all, :conditions => {writing_journal_category_id: category_id}).desc( :is_top, :title ) diff --git a/vendor/built_in_modules/personal_journal/db/seeds.rb b/vendor/built_in_modules/personal_journal/db/seeds.rb index ceb5035a7..c9de3f1cd 100644 --- a/vendor/built_in_modules/personal_journal/db/seeds.rb +++ b/vendor/built_in_modules/personal_journal/db/seeds.rb @@ -13,10 +13,8 @@ end FactoryGirl.create(:journal_co_author_relation) end -4.times do - 50.times do - FactoryGirl.create(:writing_journal) - end +50.times do + FactoryGirl.create(:writing_journal) end 50.times do