Is your plugin hosted on GitHub? Make sure to press the "fetch" button next to the repository field to fetch your plugin's info from GitHub rather than typing it all in.
Repository
Name
Home Page
Short description Adds validation scenarios support to an Active Record model.
Description ===Usage First, in your models, you declare validation scenarios details using when_scenario_is method. In the following example, both User and Address models have user_registration and profile_update scenarios declared: class User < ActiveRecord::Base has_one :address when_scenario_is :user_registration do |this| this.validates_presence_of :email this.validates_associated :address end when_scenario_is :profile_update do |this| this.validates_presence_of :first_name :unless => :something_here end end class Address < ActiveRecord::Base belongs_to :user when_scenario_is :user_registration do |this| this.validates_numericality_of :postcode end when_scenario_is :profile_update do |this| this.validates_presence_of :street_address_1 this.validates_presence_of :city end end Then, when you want to process, for example, the user_registration scenario - you just start it using: ActiveRecord::Base.with_validation_scenario method. In the following example it validates User object per rules declared for user_registration scenario. Please also note that associated Address instance is also aware that the current validation scenario is user_registration. That's why the following test passes: ActiveRecord::Base.with_validation_scenario(:user_registration) do user = User.new(:email => "foo@bar.baz") user.build_address(:postcode => 'intentionally_not_numerical') assert !user.save assert user.errors.invalid?(:address) assert_match(/is not a number/i, user.address.errors.on(:postcode)) end
Description format RDoc MarkDown Textile
License Ruby's Rails' (MIT) GPL LGPL BSD Apache Artistic PublicDomain BSD-type Free-Trial Free-but-Restricted OpenSource Proprietary Shareware Source-available-proprietary Commercial
Category Assets Controllers Internationalization Misc. Enhancements Model Rails Engines Searching and Queries Security Statistics and Logs Testing View Extensions