correct model method
This commit is contained in:
parent
84afbfa86c
commit
95805cfdee
|
@ -42,7 +42,6 @@ class WritingConference
|
||||||
validates :paper_title, :at_least_one => true
|
validates :paper_title, :at_least_one => true
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
after_save :save_writing_conference_files
|
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?}
|
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
|
attr_reader :author_tokens
|
||||||
|
@ -64,19 +63,6 @@ class WritingConference
|
||||||
self.conference_co_author_ids = authors_ids
|
self.conference_co_author_ids = authors_ids
|
||||||
end
|
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 )
|
def self.search( category_id = nil )
|
||||||
if category_id.to_s.size > 0
|
if category_id.to_s.size > 0
|
||||||
find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title )
|
find(:all, :conditions => {writing_conference_category_id: category_id}).desc( :is_top, :title )
|
||||||
|
|
|
@ -13,11 +13,9 @@ end
|
||||||
FactoryGirl.create(:journal_co_author_relation)
|
FactoryGirl.create(:journal_co_author_relation)
|
||||||
end
|
end
|
||||||
|
|
||||||
4.times do
|
|
||||||
50.times do
|
50.times do
|
||||||
FactoryGirl.create(:writing_journal)
|
FactoryGirl.create(:writing_journal)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
50.times do
|
50.times do
|
||||||
FactoryGirl.create(:journal_co_author)
|
FactoryGirl.create(:journal_co_author)
|
||||||
|
|
Loading…
Reference in New Issue