Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use rails 3 validation style

  • Loading branch information...
commit f730865ea0b09b91e099a1560c0af66a325ad453 1 parent 4dd1606
@nickrivadeneira nickrivadeneira authored
View
4 app/models/dependency.rb
@@ -9,8 +9,8 @@ class Dependency < ActiveRecord::Base
:parse_gem_dependency
after_create :push_on_to_list
- validates_presence_of :requirements
- validates_inclusion_of :scope, :in => %w( development runtime )
+ validates :requirements, :presence => true
+ validates :scope, :inclusion => {:in => %w(development runtime)}
attr_accessor :gem_dependency
View
2  app/models/ownership.rb
@@ -2,7 +2,7 @@ class Ownership < ActiveRecord::Base
belongs_to :rubygem
belongs_to :user
- validates_uniqueness_of :user_id, :scope => :rubygem_id
+ validates :user_id, :uniqueness => {:scope => :rubygem_id}
before_create :generate_token
before_destroy :keep_last_owner
View
3  app/models/rubygem.rb
@@ -12,8 +12,7 @@ class Rubygem < ActiveRecord::Base
has_one :linkset, :dependent => :destroy
validate :ensure_name_format
- validates_presence_of :name
- validates_uniqueness_of :name
+ validates :name, :presence => true, :uniqueness => true
def self.with_versions
where("rubygems.id IN (SELECT rubygem_id FROM versions where versions.indexed IS true)")
View
2  app/models/subscription.rb
@@ -2,5 +2,5 @@ class Subscription < ActiveRecord::Base
belongs_to :rubygem
belongs_to :user
- validates_uniqueness_of :rubygem_id, :scope => :user_id
+ validates :rubygem_id, :uniqueness => {:scope => :user_id}
end
View
5 app/models/version.rb
@@ -7,8 +7,9 @@ class Version < ActiveRecord::Base
after_create :full_nameify!
after_save :reorder_versions
- validates_format_of :number, :with => /\A#{Gem::Version::VERSION_PATTERN}\z/
- validates_format_of :platform, :with => Rubygem::NAME_PATTERN
+ validates :number, :format => {:with => /\A#{Gem::Version::VERSION_PATTERN}\z/}
+ validates :platform, :format => {:with => Rubygem::NAME_PATTERN}
+
validate :platform_and_number_are_unique, :on => :create
validate :authors_format, :on => :create
Please sign in to comment.
Something went wrong with that request. Please try again.