Permalink
Browse files

fixing load issues

  • Loading branch information...
1 parent 7d773f3 commit 266a14464543790bf123ac81379b82147ea3cfea @scharfie committed Jul 7, 2012
Showing with 12 additions and 20 deletions.
  1. +2 −6 lib/form_assistant.rb
  2. +10 −2 lib/form_assistant/form_builder.rb
  3. +0 −12 lib/form_assistant/railtie.rb
View
@@ -2,10 +2,6 @@
require 'form_assistant/field_errors'
require 'form_assistant/rules'
require 'form_assistant/form_builder'
+require 'form_assistant/view_helpers'
-if defined?(Rails::Railtie)
- require 'form_assistant/railtie'
-else
- require 'form_assistant/view_helpers'
- ActionView::Base.send :include, RPH::FormAssistant::ViewHelpers
-end
+ActionView::Base.send :include, RPH::FormAssistant::ViewHelpers
@@ -56,15 +56,23 @@ class << self
# set to true if you'd rather use #error_messages_for()
@ignore_errors = false
+
+ def view_path
+ if Rails.configuration.respond_to?(:view_path)
+ return Rails.configuration.view_path
+ else
+ return Rails.configuration.paths['app/views'].first
+ end
+ end
# sets the root directory where templates will be searched
# note: the template root should be nested within the
# configured view path (which defaults to app/views)
def template_root(full_path = false)
- @template_root ||= File.join(Rails.configuration.view_path, 'forms')
+ @template_root ||= File.join(view_path, 'forms')
# render(:partial => '...') doesn't want the full path of the template
- full_path ? @template_root : @template_root.gsub(Rails.configuration.view_path + '/', '')
+ full_path ? @template_root : @template_root.gsub(view_path, '')
end
end
@@ -1,12 +0,0 @@
-require 'form_assistant/view_helpers'
-
-module RPH
- module FormAssistant
- class Railtie < Rails::Railtie
- initializer "form_assistant.view_helpers" do |app|
- ActionView::Base.send :include, ViewHelpers
- end
- end
- end
-end
-

0 comments on commit 266a144

Please sign in to comment.