Sub Zero
2012-Jun-07 07:55 UTC
Couldn''t reload a module when it''s changed. Tried :require_dependency, :watchable_dirs, :unloadable
I''m completely messed with module reloading in development mode. I have
to restart app server each time I edit lib/z/nginx.rb which is included
in app/models/user_case.rb
app/models/user_case.rb
require_dependency ''z/nginx''
class UserCase < ActiveRecord::Base
include Z::Nginx
unloadable
I added to environment.rb
config.watchable_dirs[''lib''] = [:rb]
config.watchable_dirs[''lib/z''] = [:rb]
ActiveSupport::Dependencies.explicitly_unloadable_constants +%w[Z::Nginx
UserCase]
But that doesn''t work for me. When I change a string value, which is
returned by the module method, I get in a view the old value until app
server restarted.
How can I get the new value without restaring app server?
Rails 3.2.3
--
Posted via http://www.ruby-forum.com/.
--
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.
Oscar Del Ben
2012-Jun-07 14:29 UTC
Re: Couldn''t reload a module when it''s changed. Tried :require_dependency, :watchable_dirs, :unloadable
You need to use autoload_paths:
config.autoload_paths += %W(#{config.root}/lib)
--
Oscar Del Ben
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
On Thursday, June 7, 2012 at 12:55 AM, Sub Zero wrote:
> I''m completely messed with module reloading in development mode. I
have
> to restart app server each time I edit lib/z/nginx.rb which is included
> in app/models/user_case.rb
>
> app/models/user_case.rb
> require_dependency ''z/nginx''
> class UserCase < ActiveRecord::Base
> include Z::Nginx
> unloadable
>
> I added to environment.rb
> config.watchable_dirs[''lib''] = [:rb]
> config.watchable_dirs[''lib/z''] = [:rb]
> ActiveSupport::Dependencies.explicitly_unloadable_constants +>
%w[Z::Nginx UserCase]
>
> But that doesn''t work for me. When I change a string value, which
is
> returned by the module method, I get in a view the old value until app
> server restarted.
>
> How can I get the new value without restaring app server?
>
> Rails 3.2.3
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
(mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org).
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
(mailto:rubyonrails-talk+unsubscribe-/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.
Richard Ma
2012-Jun-07 14:42 UTC
Re: Couldn''t reload a module when it''s changed. Tried :require_dependency, :watchable_dirs, :unloadable
Rails 3.x will support the autoload feature... On Thu, Jun 7, 2012 at 10:29 PM, Oscar Del Ben <oscar.delben-x2GpsThumDamLaUXeIOdZg@public.gmane.org> wrote:> You need to use autoload_paths: > > config.autoload_paths += %W(#{config.root}/lib) > > -- > Oscar Del Ben > Sent with Sparrow <http://www.sparrowmailapp.com/?sig> > > On Thursday, June 7, 2012 at 12:55 AM, Sub Zero wrote: > > I''m completely messed with module reloading in development mode. I have > to restart app server each time I edit lib/z/nginx.rb which is included > in app/models/user_case.rb > > app/models/user_case.rb > require_dependency ''z/nginx'' > class UserCase < ActiveRecord::Base > include Z::Nginx > unloadable > > I added to environment.rb > config.watchable_dirs[''lib''] = [:rb] > config.watchable_dirs[''lib/z''] = [:rb] > ActiveSupport::Dependencies.explicitly_unloadable_constants +> %w[Z::Nginx UserCase] > > But that doesn''t work for me. When I change a string value, which is > returned by the module method, I get in a view the old value until app > server restarted. > > How can I get the new value without restaring app server? > > Rails 3.2.3 > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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. > > > -- > 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. >-- Best Regards. Richard Ma My Blog: www.richardma.org -- 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.
Sub Zero
2012-Jun-08 12:30 UTC
Re: Couldn''t reload a module when it''s changed. Tried :require_dependency, :watchable_dirs, :unloada
Oscar Del Ben wrote in post #1063552:> You need to use autoload_paths: > > config.autoload_paths += %W(#{config.root}/lib)Thank you Oscar! That works for me ) -- Posted via http://www.ruby-forum.com/. -- 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.