Forum: Ruby on Rails Adding functionality to a plugin

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 joevandyk (Guest)
on 2005-11-24 04:28
(Received via mailing list)
What's the best method of extending a plugin / engine?

In my case, I'm using the login_engine.  I want the user to also
provide their address and phone number.

Would I just directly extend the plugin code?   I wouldn't do it by
putting my code right in vendor/plugins/login_engine, right?

Joe
5190330ad8f1b06d35e2c2da73dc623c?d=identicon&s=25 eric (Guest)
on 2005-11-24 08:05
(Received via mailing list)
Joe Van Dyk wrote:
> In my case, I'm using the login_engine.  I want the user to also
> provide their address and phone number.
>
> Would I just directly extend the plugin code?   I wouldn't do it by
> putting my code right in vendor/plugins/login_engine, right?

Is is just for this app or do you plan to use this extension on multiple
apps and need it as a plugin itself. If is just for this app and you are
using a engine (which you seem to be doing) then I believe you can
simply overlay your custom views in your app/ folder and it will take
precedence over the views in the engine. If you want to add your own
custom actions you can create a controller in your app directory and it
will be mixed into the controller in the engine allowing you to override
and add actions.

Eric
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 joevandyk (Guest)
on 2005-11-24 09:34
(Received via mailing list)
On 11/23/05, Eric Anderson <eric@afaik.us> wrote:
> simply overlay your custom views in your app/ folder and it will take
> precedence over the views in the engine. If you want to add your own
> custom actions you can create a controller in your app directory and it
> will be mixed into the controller in the engine allowing you to override
> and add actions.

If I want to add a phone number and address to the login_engine, then
I'm going to need to modify the schema and possibly the model.
437ee3e09fe9539cdec6ba44153186cd?d=identicon&s=25 Will Emigh (Guest)
on 2005-11-24 10:27
joevandyk wrote:
> On 11/23/05, Eric Anderson <eric@afaik.us> wrote:
>> simply overlay your custom views in your app/ folder and it will take
>> precedence over the views in the engine. If you want to add your own
>> custom actions you can create a controller in your app directory and it
>> will be mixed into the controller in the engine allowing you to override
>> and add actions.
>
> If I want to add a phone number and address to the login_engine, then
> I'm going to need to modify the schema and possibly the model.

With the Login Engine, you can create your own user model as normal and
it will work just fine as long as you include the authenticated user
module (with 'include LoginEngine::AuthenticatedUser').
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-24 11:07
(Received via mailing list)
In your case, you'll probably want to:

1. copy then adapt the schema (the latest versions of Engines support
migrations that you can use to avoid the 'copy' part there - just add
your changes as migrations in your own application/db/migrate folder)

2. Create your own /app/models/user.rb file, remember to include
LoginEngine::AuthenticatedUser, and then add any other validation &
methods that will support your extra fields. If you don't need any
validation or any of that jazz, you won't need to create your own
model, since ActiveRecord will quite happily handle the extra fields
for you.

3. Copy & adapt any views or controller methods that will need to know
about these extra editable fields. This will probably be the show/edit
views, and the update code in the controller.

- james
This topic is locked and can not be replied to.