Permalink
Browse files

The middleware is now setup through a Rails engine

  • Loading branch information...
1 parent e6d39c6 commit 5d864c3209593a15344bca27862ec529ab7f96fd @bcardarella bcardarella committed Aug 6, 2010
Showing with 18 additions and 4 deletions.
  1. +2 −1 client_side_validations.gemspec
  2. +5 −3 lib/client_side_validations.rb
  3. +11 −0 lib/client_side_validations/rails.rb
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Brian Cardarella"]
- s.date = %q{2010-07-27}
+ s.date = %q{2010-08-06}
s.description = %q{Client Side Validations for Rails 2.x and 3.x}
s.email = %q{bcardarella@gmail.com}
s.extra_rdoc_files = [
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
"lib/client_side_validations/adapters/active_model.rb",
"lib/client_side_validations/adapters/orm_base.rb",
"lib/client_side_validations/orm.rb",
+ "lib/client_side_validations/rails.rb",
"lib/client_side_validations/template.rb",
"lib/generators/client_side_validations_generator.rb"
]
@@ -1,8 +1,6 @@
require 'rubygems'
require 'json'
require 'cgi'
-require 'client_side_validations/orm'
-require 'client_side_validations/template'
module ClientSideValidations
def self.default_options=(options)
@@ -55,4 +53,8 @@ def constantize_resource(resource)
eval(resource.split('_').map{ |word| word.capitalize}.join)
end
end
-end
+end
+
+require 'client_side_validations/orm'
+require 'client_side_validations/template'
+require 'client_side_validations/rails' if defined?(Rails)
@@ -0,0 +1,11 @@
+module ClientSideValidations
+ if Rails::VERSION::MAJOR == 3
+ class Engine < ::Rails::Engine
+ config.app_middleware.use ClientSideValidations::Uniqueness
+ end
+ else
+ Rails.configuration.after_initialize do
+ Rails.configuration.middleware.use ClientSideValidations::Uniqueness
+ end
+ end
+end

0 comments on commit 5d864c3

Please sign in to comment.