# Adding functionality to a plugin

**URL:** <https://www.ruby-forum.com/t/adding-functionality-to-a-plugin/101924>\
**Category:** Rails\
**Created:** [November 24, 2005, 4:28am UTC](https://www.ruby-forum.com/t/adding-functionality-to-a-plugin/101924 "2005-11-24T04:28:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joevandyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@joevandyk](https://www.ruby-forum.com/u/joevandyk)\
**Post date:** [November 24, 2005, 4:28am UTC](https://www.ruby-forum.com/t/adding-functionality-to-a-plugin/101924/1 "2005-11-24T04:28:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joevandyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@joevandyk](https://www.ruby-forum.com/u/joevandyk)\
**Post date:** [November 24, 2005, 8:05am UTC](https://www.ruby-forum.com/t/adding-functionality-to-a-plugin/101924/2 "2005-11-24T08:05:40Z")

</div>

Joe Van D. 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

---

<div class="post-metadata">

**Author:** ![joevandyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@joevandyk](https://www.ruby-forum.com/u/joevandyk)\
**Post date:** [November 24, 2005, 9:34am UTC](https://www.ruby-forum.com/t/adding-functionality-to-a-plugin/101924/3 "2005-11-24T09:34:21Z")

</div>

On 11/23/05, Eric A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![joevandyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@joevandyk](https://www.ruby-forum.com/u/joevandyk)\
**Post date:** [November 24, 2005, 10:27am UTC](https://www.ruby-forum.com/t/adding-functionality-to-a-plugin/101924/4 "2005-11-24T10:27:08Z")

</div>

joevandyk wrote:

> On 11/23/05, Eric A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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’).

---

<div class="post-metadata">

**Author:** ![joevandyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c0e974/32.png) [@joevandyk](https://www.ruby-forum.com/u/joevandyk)\
**Post date:** [November 24, 2005, 11:07am UTC](https://www.ruby-forum.com/t/adding-functionality-to-a-plugin/101924/5 "2005-11-24T11:07:09Z")

</div>

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
