I have a custom form builder for my application:

# file location: /lib/ruby/app_form_builder.rb

class ActionView::Helpers::AppFormBuilder < ActionView::Helpers::FormBuilder
  include ActionView::Helpers::TagHelper
  include ActionView::Context

  def foo
    'bar'
  end
end


I am requiring it in an initializer:

require "#{Rails.root}/lib/ruby/app_form_builder.rb"
ActionView::Base.default_form_builder = ActionView::Helpers::AppFormBuilder


This works, but I have to restart the server on every change. I was reading 
the Constant Guide 
<http://edgeguides.rubyonrails.org/autoloading_and_reloading_constants.html>, 
but didn't find the right way to made this file to be automaticaly 
reloaded. I tried to put this in /app/helpers forlder and making it default 
in application.rb, but I got "unitialized constant" error.

Also, I would like to know if Rails can reload code that modify native Ruby 
classes:

class String
  def do_something
    'something'
  end
end




-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/a5fb430f-6b1e-4843-ac56-a5fe9e663a1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to