Hello everyone, I am trying to set a default custom form builder. I have defined my form builder class in "lib/mymodule/mybuilder.rb" as: module Mymodule class Mybuilder < ActionView::Helpers::FormBuilder ...... end end Then I am trying to use this custom class in application.rb as config.action_view.default_form_builder = Mymodule::Mybuilder. But I get "Uninitialized constant error." Does this mean that my module stored in "lib" directory is not loaded automatically? Thanks in advance, p.s. I am a newbie to Ruby and Rails as well. I can''t really understand the module and class loading process in rails. I will appreciate if someone explains me a little bit which folders are loaded in initialization process, which I should "require ''someclass''" explicitly. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I gueuss it''s due to the fact your ''lib/mymodule/mybuilder.rb'' isn''t required yet, do this in the config/environment.rb where you have the line: config.action_view.default_form_builder = Mymodule::Mybuilder C+++ On Wed, Jun 23, 2010 at 1:39 PM, regnever <sherzod-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello everyone, > > I am trying to set a default custom form builder. > I have defined my form builder class in "lib/mymodule/mybuilder.rb" > as: > > module Mymodule > class Mybuilder < ActionView::Helpers::FormBuilder > ...... > end > end > > Then I am trying to use this custom class in application.rb as > config.action_view.default_form_builder = Mymodule::Mybuilder. But I > get "Uninitialized constant error." > > Does this mean that my module stored in "lib" directory is not loaded > automatically? > > Thanks in advance, > > p.s. I am a newbie to Ruby and Rails as well. I can''t really > understand the module and class loading process in rails. I will > appreciate if someone explains me a little bit which folders are > loaded in initialization process, which I should "require ''someclass''" > explicitly. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
evnironment.rb file doesn''t contain any "config" instance or local variable. Edge rails documentation (Rails application configuration) suggests using: config.action_view.default_form_builder = MyBuilder inside application.rb file. I just cant figure out Where to store my modules/classes in order to be able to set that configuration int application.rb file. On Jun 23, 9:57 pm, Christiaan Van den Poel <vandenpoel.christi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I gueuss it''s due to the fact your ''lib/mymodule/mybuilder.rb'' isn''t > required yet, do this in the config/environment.rb where you have the line: > > config.action_view.default_form_builder = Mymodule::Mybuilder > > C+++ > > On Wed, Jun 23, 2010 at 1:39 PM, regnever <sher...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello everyone, > > > I am trying to set a default custom form builder. > > I have defined my form builder class in "lib/mymodule/mybuilder.rb" > > as: > > > module Mymodule > > class Mybuilder < ActionView::Helpers::FormBuilder > > ...... > > end > > end > > > Then I am trying to use this custom class in application.rb as > > config.action_view.default_form_builder = Mymodule::Mybuilder. But I > > get "Uninitialized constant error." > > > Does this mean that my module stored in "lib" directory is not loaded > > automatically? > > > Thanks in advance, > > > p.s. I am a newbie to Ruby and Rails as well. I can''t really > > understand the module and class loading process in rails. I will > > appreciate if someone explains me a little bit which folders are > > loaded in initialization process, which I should "require ''someclass''" > > explicitly. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Christiaan Van den Poel
2010-Jun-24 08:27 UTC
Re: Re: Custom default form builder in Rails 3
My mistake then, sorry for that. So when you do a require ''your/module'' in the application.rb doesn''t this works? On Wed, Jun 23, 2010 at 3:22 PM, regnever <sherzod-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> evnironment.rb file doesn''t contain any "config" instance or local > variable. > Edge rails documentation (Rails application configuration) suggests > using: > > config.action_view.default_form_builder = MyBuilder > > inside application.rb file. > > I just cant figure out Where to store my modules/classes in order to > be able to set that configuration > int application.rb file. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.