I think the issue you're describing is this - please correct me if I'm wrong:
* Savage beast contains a User class
* Your application is trying to re-open the User class to add methods to it
* However, when the application runs, none of your custom methods
appear on the User class.
If this is the case, it sounds like a fairly common thing. The key is
that model classes are not (at the moment) automatically mixed in the
same way that Controllers and Helpers are.
Instead, you need to ensure that both the plugin class AND your
application class is loaded. Your application's class should be higher
in the load path, so if you "require 'user'", it should be that
app/models/user.rb will be loaded, but you can check this put putting
some 'puts' statements in to check. If everything is as expected, you
should then be able to explicitly require the user class from the
Savage Beast plugin at the top of this file, and then re-open the
class to add your methods.
It's possible that the Savage Beast plugin references its own User
class explicitly before you have the chance to load the one in your
application - again, puts statements will shine a light on what's
going on behind the scenes.
James
On 29 Jan 2008 20:06:03 -0800, Robert Alford <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> I'm not positive if this is a Engines bug, but it seems very peculiar and a
> few hours of Googling haven't given me any good leads yet, so I thought I'd
> see if it makes sense to any of you:
>
> I am writing a new version of the savage_beast plugin (implements Beast
> forums as a plugin) that's Rails 2.0 compatible, and I am having trouble
> with the many models in the plugin that refer to the User model (which lives
> in my project). For example, my Post class (part of the savage_beast
> plugin) has
>
> class Post < ActiveRecord::Base
> belongs_to :forum
> belongs_to :user
> belongs_to :topic
>
> ...
> end
>
> I can set the forum, user, and topic for this class fine, and they save
> without issue. However, when I go to access the user association later on,
> I can only get its database fields, not any of the methods that are defined
> in the User model. That is,
>
> @post.user[:some_database_attribute] will display fine
> @post.user.any_method_at_all will give me a "No method found" error.
>
> If I check what kind of class @post.user is, Ruby will report it is a "User"
> class as usual. I have tried to hack around this by doing a def user {
> User.find(user_id) } in the plugin, but users are used as associations in
> numerous instances in numerous models, sometimes as has_many_throughs, so
> besides being ugly, I don't think this hack is going to be viable across the
> board (though doing a User.find of the user_id does return a model with
> methods intact).
>
> Do any of you have any suggestions about how I could fix (or start to debug)
> this issue?
>
> Thanks,
> Bill Harding
>
>
>
>
> _______________________________________________
> Engine-Users mailing list
> [email protected]
> http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org
>
>
--
* J *
~
_______________________________________________
Engine-Users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org