From c90aaf5b877d19e7a51e0dd4542214ca88ca66fe Mon Sep 17 00:00:00 2001 From: Alinson S Xavier Date: Thu, 11 Jul 2013 18:48:54 -0400 Subject: [PATCH] Getting rid of dr_nic_magic_models --- app/models/attachment.rb | 4 +++- app/models/course.rb | 6 +++++- app/models/event.rb | 2 +- app/models/wiki_page.rb | 4 +++- config/environment.rb | 1 - rvm-use | 1 + 6 files changed, 13 insertions(+), 5 deletions(-) create mode 100755 rvm-use diff --git a/app/models/attachment.rb b/app/models/attachment.rb index bd95abb..6464745 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -25,7 +25,9 @@ class Attachment < ActiveRecord::Base belongs_to :course # Validacao - generate_validations + validates_presence_of :file_name + validates_numericality_of :size, :allow_nil => true, :only_integer => true + validates_inclusion_of :front_page, :in => [true, false], :allow_nil => false, :message => ActiveRecord::Errors.default_error_messages[:blank] def self.find_front_page Attachment.find(:all, :conditions => [ "front_page = ?", true ]) diff --git a/app/models/course.rb b/app/models/course.rb index 52db217..f19fd18 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -45,7 +45,11 @@ class Course < ActiveRecord::Base :order => "last_seen desc" # Validacao - generate_validations + validates_presence_of :short_name + validates_presence_of :full_name + validates_presence_of :code + validates_numericality_of :grade, :only_integer => true + validates_inclusion_of :hidden, :in => [true, false], :allow_nil => false validates_format_of :short_name, :with => /^[^0-9]/ def related_courses diff --git a/app/models/event.rb b/app/models/event.rb index 7ba54e8..4e20a75 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -26,7 +26,7 @@ class Event < ActiveRecord::Base belongs_to :course # Validacao - generate_validations + validates_presence_of :title def Event.to_ical(courses) courses = [courses] unless courses.kind_of?(Array) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 419b1ee..7ab3ba6 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -35,7 +35,9 @@ class WikiPage < ActiveRecord::Base belongs_to :user, :with_deleted => true # Valicacao - generate_validations + validates_presence_of :description + validates_presence_of :title + validates_presence_of :content validates_uniqueness_of :title, :scope => :course_id validates_uniqueness_of :canonical_title, :scope => :course_id validates_format_of :title, :with => /^[^0-9]/ diff --git a/config/environment.rb b/config/environment.rb index b876f3b..b7e1c96 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -73,7 +73,6 @@ Rails::Initializer.run do |config| noresize nowrap rel rows rowspan rules scope shape size span src start style summary title type usemap valign width) - config.gem "dr_nic_magic_models" config.gem "bluecloth" config.gem "haml" config.gem "hpricot" diff --git a/rvm-use b/rvm-use new file mode 100755 index 0000000..35b9456 --- /dev/null +++ b/rvm-use @@ -0,0 +1 @@ +rvm use ruby-1.8.7-p374@wikiufc-1.1