How to include login_engine pages in my own views?

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

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. [email protected] wrote:

Posted via http://www.ruby-forum.com/.


engine-users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org

  • J *
    ~

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

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. [email protected] 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/.


engine-users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org

  • J *
    ~

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

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

On 2/17/06, Mike M. [email protected] wrote:


Posted via http://www.ruby-forum.com/.


engine-users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org

  • J *
    ~

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