Forum: Rails Engines How to include login_engine pages in my own views?

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.
Mike M. (Guest)
on 2006-02-13 23:42
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
James A. (Guest)
on 2006-02-16 00:30
(Received via mailing list)
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> wrote:
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> engine-users mailing list
> removed_email_address@domain.invalid
> http://lists.rails-engines.org/listinfo.cgi/engine...
>


--
* J *
  ~
Mike M. (Guest)
on 2006-02-17 19:08
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
James A. (Guest)
on 2006-02-17 19:15
(Received via mailing list)
What I'm suggesting is that you first define a layout for your
application, in /app/views/layouts/my_layout.rhtml:

<html><body><div id='header'><%= render_partial 'shared/my_header'
%></div>
<div id='content'><%= @content_for_layout %></div></body></html>

... and then the corresponding header partial, in
/app/views/shared/_my_header.rhtml:

<h1>My Great app!</h1>  <!-- or whatever -->

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> 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
> removed_email_address@domain.invalid
> http://lists.rails-engines.org/listinfo.cgi/engine...
>


--
* J *
  ~
Mike M. (Guest)
on 2006-02-17 21:35
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
James A. (Guest)
on 2006-02-19 19:08
(Received via mailing list)
This probably won't work because the UserController simply isn't a
component.

On 2/17/06, Mike M. <removed_email_address@domain.invalid> wrote:
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> engine-users mailing list
> removed_email_address@domain.invalid
> http://lists.rails-engines.org/listinfo.cgi/engine...
>


--
* J *
  ~
Mike M. (Guest)
on 2006-02-20 22:49
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
This topic is locked and can not be replied to.