Overriding sign in views

316 views
Skip to first unread message

Chris White

unread,
Nov 25, 2009, 7:49:49 PM11/25/09
to Devise
Having a bit of a conceptual problem. We are developing a site that
has sign in and sign up on the home page and nowhere else. We are
having some difficulty figuring out how to override the Devise view
for sessions#new so it renders the home page when there are errors
authenticating.

We have tried messing with map.devise_for to create a new route for
sessions#new with little successful. We looked at
Devise::Controllers::Filters and didn't see anything that would help
as well.

Any suggestions? Thanks in advance...

--Chris White

José Valim

unread,
Nov 25, 2009, 7:57:51 PM11/25/09
to plataforma...@googlegroups.com
You can run:

script/generate devise_views

And customize your sessions/new to be your home page.

Then you can follow the tweaks on this topic:


To make SessionsController#new to be your root path.
--
José Valim

Director of Engineering - Plataforma Tecnologia
http://blog.plataformatec.com.br/

rasmusrn

unread,
Dec 9, 2009, 4:59:41 PM12/9/09
to Devise
José,

What should I do if I wanted a login form on multiple pages? Say on
the frontpage and on /login like the way Facebook has. If you type
wrong email/password on the form on the frontpage you're sent to the
dedicated /login page, where you will able to try again.

Thanks in advance :-)

On Nov 26, 1:57 am, José Valim <jose.va...@gmail.com> wrote:
> You can run:
>
> script/generate devise_views
>
> And customize your sessions/new to be your home page.
>
> Then you can follow the tweaks on this topic:
>
> http://groups.google.com/group/plataformatec-devise/browse_thread/thr...

Mike

unread,
Dec 9, 2009, 5:21:52 PM12/9/09
to Devise
There's nothing forcing you to use sessions/new.html.erb as your sign
in location.

I just moved my sign in screen to a random place in the app and it
worked fine. If you are using the devise generated views you'll have
to rename the "resource_name" variables to actual variables (like
@user) and you apparently don't have the devise.mapping methods
available, but it seems to work. Again, I spent about 1 minute on
this, so there may be a way to get access to the devise.mapping if you
need it.

Just do a regular post to sessions_path(@user) and you should get a
valid signin.

Jose - correct me if i'm wrong.

Mike

unread,
Dec 9, 2009, 5:23:18 PM12/9/09
to Devise
Forgot to mention that I moved the sign-in form off into a partial
that was loaded by sessions/new before and now it's loaded by
random_page/index

José Valim

unread,
Dec 9, 2009, 5:24:15 PM12/9/09
to plataforma...@googlegroups.com
Mike, you are right! :)

We just have devise.mappings and friends on Devise to make it work for any resource. You don't need them, you can simply hardcode it, like Mike done with @user.

rasmusrn

unread,
Dec 10, 2009, 3:30:02 PM12/10/09
to Devise
Mike, I should have tried that before asking here. Thank you for
replying.
Reply all
Reply to author
Forward
0 new messages