The problem is that your extensions (in lib/blog_engine_ext.rb) are
only being loaded once, at the bottom of environment.rb (the require
statement).
When the system reloads, there's nothing to trigger the re-inclusion
of your code, and so the Post model ends up in a bit of a freaky
state.
The solution is simple; any kind of functionality injection should be
performed in a config.to_prepare block. This goes for the contents of
init.rb, along with the approach that you're taking.
I've changed environment.rb as below, and the app now works for every
subsequent request:
Rails::Initializer.run do |config|
# etc
config.to_prepare do
# use load to ensure that the file is actually evaluated every
time
load 'blog_engine_ext.rb'
end
end
# no require needed.
Hope that helps,
- James
On Aug 13, 9:05 am, Oriol Gual <[email protected]> wrote:
> I am also experiencing these problems, any news on this?
>
> Thanks.
>
> On 1 Jul, 22:01, Anders Jacobsen <[email protected]> wrote:
>
>
>
> > I am experiencing the same problems as Brent: when a plugin extends an
> > application model, things work as expected in production mode while
> > development mode is buggy.
> > I tried both of Paul's suggestions, but still no success ...
>
> > -Anders
>
> > On 7 Maj, 13:06, Pau Cor <[email protected]> wrote:
>
> > > Brent Dillingham wrote:
> > > > Can anyone tell me the "proper" way to extend a model provided by an
> > > > app engine (or any plugin for that matter).
>
> > > I *think* that you can do it in one of these two ways:
>
> > > First, you could put something like this in your plugin’s init.rb file:
> > > # This plugin should be reloaded in development mode.
> > > if RAILS_ENV == ‘development’
> > > ActiveSupport::Dependencies.load_once_paths.reject!{|x| x =~
> > > /^#{Regexp.escape(File.dirname(__FILE__))}/}
> > > end
>
> > > Second, you could put something like this in your application’s
> > > environment.rb file:
> > > config.reload_plugins = true if RAILS_ENV == ‘development’
> > > --
> > > Posted viahttp://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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---