# How to include login\_engine pages in my own views?

**URL:** <https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711>\
**Category:** Engines\
**Created:** [February 13, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711 "2006-02-13T22:42:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [February 13, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711/1 "2006-02-13T22:42:33Z")

</div>

I installed the login\_engine and all works fine but when I log in I am  
redirected to a login page which looks like it’s not part of my site  
because it has different formatting and none of my headings ( partials  
on top of page ). Is there a way for me to include say the login page or  
the edit account page inside of my own views? I tried render(:file) but  
that didn’t work, there must be some smart way of doing this.  
Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [February 15, 2006, 11:30pm UTC](https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711/2 "2006-02-15T23:30:12Z")

</div>

Have you tried setting a layout? If you need to set an explicit  
layout, just override the UserController in your application (read the  
Engines documentation for more details) and add a line like:

layout “my\_layout\_which\_includes\_partials\_etc”

- james

On 2/13/06, Mike M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [February 17, 2006, 6:08pm UTC](https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711/3 "2006-02-17T18:08:26Z")

</div>

I haven’t tried the layout suggestion, I’m not sure I understand what to  
do with it.  
Here is what I’m trying to do. I have my own controller called called  
say ‘mike’. All my pages need to have a header even if users are not  
logged in. On the home page I need to display the header and below it  
the login screen. Once they log in they should see the entire page  
including the header which will always be there.  
I have tried using \<%= render\_component(:controller =\> ‘user’, :action  
=\> ‘login’) %\> at the bottom of my \_header.rhtml, this shows the login  
screen where I want it but when I click on login button or Register for  
an account | Forgot my password links, it complains that it can’t find  
action mike/login, why did the login screen all of the sudden pickup my  
controller name instead of using user/login. I can change the links to  
point to the user controller but not the login button. After a while of  
reading the Engines documentation and other wikis, I created an  
app/views/user directory and put login.rhtml there, created an empty  
user\_controller.rb in my app/controllers directory. Then something  
strange started happening all all pages render as blank and I get like  
20 pages of errors in my webrick window, I can’t even see the top most  
message because there are so many errors. Not sure why that happened.  
For now I’ll just stick with putting a link to the user/login screen and  
users will go to that plain login page and then be routed back to my  
page. I have also tried putting the user/login page as the first page  
and attaching my header to the top of it but I can’t find the header  
because it’s not in the views/user/ directory.  
So far the login\_engine works great for me with the exception of being  
able to include it inside my own views. I probably need to read up and  
experiment more with it.  
Thanks for your help.  
Mike

---

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [February 17, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711/4 "2006-02-17T18:15:29Z")

</div>

What I’m suggesting is that you first define a layout for your  
application, in /app/views/layouts/my\_layout.rhtml:

\<%= render\_partial 'shared/my\_header' %\>

\<%= @content\_for\_layout %\>

… and then the corresponding header partial, in  
/app/views/shared/\_my\_header.rhtml:

# My Great app!

Then, to make sure that the login engine renders its views using your  
layout, create a UserController in your own application to be mixed in  
to the engine one -

/app/controllers/user\_controller.rb:  
class UserController \< ApplicationController  
layout ‘my\_layout’  
end

This means that all of the UserController actions (from the engine)  
should now be rendered with your custom layout, i.e. including the  
header.

Does that make sense?

- james

On 2/17/06, Mike M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> an account | Forgot my password links, it complains that it can’t find  
> users will go to that plain login page and then be routed back to my  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [February 17, 2006, 8:35pm UTC](https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711/5 "2006-02-17T20:35:50Z")

</div>

Thanks, that really explained a lot for me.  
Everything seems fine except for the situation where I’m calling \<%=  
render\_component(:controller =\> ‘user’, :action =\> ‘login’) %\> in my  
app/views/mike/index.rhtml. My header shows up and the login screen  
below, but when I click login it complains that it can’t find action  
mike/user

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [February 19, 2006, 6:08pm UTC](https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711/6 "2006-02-19T18:08:33Z")

</div>

This probably won’t work because the UserController simply isn’t a  
component.

On 2/17/06, Mike M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![mike-moscow](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/53a042/32.png) [@mike-moscow](https://www.ruby-forum.com/u/mike-moscow)\
**Post date:** [February 20, 2006, 9:49pm UTC](https://www.ruby-forum.com/t/how-to-include-login-engine-pages-in-my-own-views/53711/7 "2006-02-20T21:49:22Z")

</div>

I got it to work by following your suggestion about using my layout in  
the user\_controller and I scrapped the render\_component idea.  
Thanks a lot for your help.  
Mike
