Forum: Rails Engines How to dynamically buid relationships between models?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Joshua M. (Guest)
on 2006-05-21 15:50
Hi all

I'm trapped with the following problem.

I'd like to work with the UserEngine engine. Every user has let's say a
Profile model. So they have a 1:1 relationship.

Now I should declare this relationship in both models. But where do I
have to declare it exactly in the User model? I see they are working
somehow with modules in the engine's lib dir, but how does this work
exactly? I'm quite confused... :-/

Thanks for explanation of this topic. :-)
James A. (Guest)
on 2006-05-22 01:42
(Received via mailing list)
For information about adding application-specific functionality to
models which are supplied by engines, please read the engines' README
(in the engines plugin), and this:

- james
Vincent AE Scott (Guest)
on 2006-05-26 16:24
(Received via mailing list)
#if forum /* May 21, 01:50 */
> exactly? I'm quite confused... :-/
> Thanks for explanation of this topic. :-)
> Joshua
#endif /* removed_email_address@domain.invalid */

if i understand you correctly, you want to augment the User model with
some extra relationships?  If thats the case, then something like the
following might help you:

I have a model called "Person", that looks something like this:


class Person < User
 has_many :settings, :class_name => "UserSetting" do
  def default_users_acl_name
   acl_name = find_by_property("DefaultACL").value

The "User" class comes from

Then, whenever i want to use my extra functionality to the User model i
just go via People instead:

p = Person.find_by_login("admin")

p = Person.find(1)
etc, etc.

This way, i can let user/login engine do all its clever stuff, but i
dont have to make any changes to that code base

does that help?


P.S. dont be offended by the quote, its randomly generated


 There are only two truly infinite things, the universe and stupidity.
 And I am unsure about the universe.
 -- Albert Einstein
This topic is locked and can not be replied to.