# Engine and controller layout confusion

**URL:** <https://www.ruby-forum.com/t/engine-and-controller-layout-confusion/51569>\
**Category:** Rails\
**Created:** [January 3, 2006, 3:08pm UTC](https://www.ruby-forum.com/t/engine-and-controller-layout-confusion/51569 "2006-01-03T15:08:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 3, 2006, 3:08pm UTC](https://www.ruby-forum.com/t/engine-and-controller-layout-confusion/51569/1 "2006-01-03T15:08:31Z")

</div>

Hi all,

Installed the login\_engine which is working. But I’m confused as to how  
I tell  
Rails to use the “/app/views/layout” rhtml files, when partials from the  
login\_engine are used from  
“/vendor/plugins/login\_engine/app/views/user”.

Do I copy login.rhtml to /app/view/mgmt?  
(mgmt is a controller name in my app)

Along the same line:

I also have a nil error on the line below:  
if session[:user] = User.authenticate(params[:user][:login],  
params[:user]  
[:password])

Which seems correct (isn’t it?) because it’s in application.rb and the  
login\_engine use a model called user seemingly unknown in the  
ApplicationController?

Can somebody tell me how to stick to Rails protocol on this?

Big thanx!

Grtz Gerard.

–  
“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 4, 2006, 11:12am UTC](https://www.ruby-forum.com/t/engine-and-controller-layout-confusion/51569/2 "2006-01-04T11:12:27Z")

</div>

On 1/3/06, Gerard [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Installed the login\_engine which is working. But I’m confused as to how I tell  
> Rails to use the “/app/views/layout” rhtml files, when partials from the  
> login\_engine are used from “/vendor/plugins/login\_engine/app/views/user”.

Rails will use _any_ views in your /app/views/ subfolders in  
precidence over anything in the login engine.

> Do I copy login.rhtml to /app/view/mgmt?  
> (mgmt is a controller name in my app)

Umm… are you saying that you want to use your ‘mgmt’ controller to  
login? I’m not sure what you mean here, or rather what problem you are  
trying to solve.

> I also have a nil error on the line below:  
> if session[:user] = User.authenticate(params[:user][:login], params[:user]  
> [:password])
> 
> Which seems correct (isn’t it?) because it’s in application.rb and the  
> login\_engine use a model called user seemingly unknown in the  
> ApplicationController?

Have you followed the installation instructions for the login engine?  
If there is no ‘User’ model available, most likely you either

a) haven’t installed the Engines plugin  
b) haven’t inserted a call to Engines.start at the bottom of your  
environment.rb file  
c) both of the above

- james

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 4, 2006, 11:30am UTC](https://www.ruby-forum.com/t/engine-and-controller-layout-confusion/51569/3 "2006-01-04T11:30:40Z")

</div>

James,

thanx for the response. Replies inline …

> > Do I copy login.rhtml to /app/view/mgmt?  
> > (mgmt is a controller name in my app)
> 
> Umm… are you saying that you want to use your ‘mgmt’ controller to  
> login? I’m not sure what you mean here, or rather what problem you are  
> trying to solve.  
> login.rhtml didn’t have the css layout I wanted. I did a symlink to  
> another  
> file. (and copied the user model. See below)  
> -rw-r----- 1 aaaaaa aaaaa 1402 Jan 4 11:19 mgmt.rhtml  
> lrwxrwxrwx 1 aaaaaa aaaaa 10 Jan 4 11:05 user.rhtml -\> mgmt.rhtml

> > Which seems correct (isn’t it?) because it’s in application.rb and the  
> > login\_engine use a model called user seemingly unknown in the  
> > ApplicationController?
> 
> Have you followed the installation instructions for the login engine?  
> If there is no ‘User’ model available, most likely you either  
> The user model was there but hidden in vendor/plugin/login\_engine  
> somewhere.

I copied this one to /app/controllers/user\_controller.rb. This works  
now,  
however there’s one question. I couldn’t get it working properly without  
copying the user\_controller.rb from the plugin directory to the  
app/controller directory. Now it does all work. But if a newer version  
of the  
plugin is downloaded i’ve got two version in my environment. (I must  
admit  
I’m happy the way it works now btw).

And should I try to figure out how to make it work in th  
plugin/…controller  
directory and download a new version. My changes are lost.

Any suggestions on what’s best practice in this case?

A very big thanx!

Regards,

Gerard.

–  
“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!
