Hi, I’ve just gotten started with devise and it’s pretty nifty. I just
wondered if people could point me in the right direction for finding
info about 3 things.
-
How come the login form does not report error messages when the
username/password is incorrect? I generated the views and replaced the
form. I don’t think I got rid of anything that would cause these
errors to disappear, but I obviously must have.
How can I get this error message back?
-
I have created custom methods for “inactive_message” and “active?”,
but the devise login form doesn’t appear to be using them. How can I
get devise to not log a user in when “active?” return false? The
documentation says it should… but it’s not working. What do I need
to enable to get this behaviour?
-
For the registration page, I’d like to customize what the initial
object is - it’s a different subclass of the class knows about. I
don’t want to generate new controllers for this subclass just to get a
different registration page. How can do that? I also want to add yet
another registration page for a different user role - again, not
creating the rest of the controllers (they are not needed).
If these 3 questions mean I starting to push the bounds of what Devise
was designed to do, then I guess I’d also like to know that as well.
If I have to swap it out for a custom authentication system, it’s good
to know that 
Thanks!
On Thu, May 19, 2011 at 7:21 PM, egervari [email protected]
wrote:
Hi, I’ve just gotten started with devise and it’s pretty nifty. I just
wondered if people could point me in the right direction for finding
info about 3 things.
- How come the login form does not report error messages when the
username/password is incorrect? I generated the views and replaced the
form. I don’t think I got rid of anything that would cause these
errors to disappear, but I obviously must have.
How can I get this error message back?
The messages are reported via the flash hash, make sure you have the 3
devise uses at all time, the best way to have all of them is iterating
the
flash hash like this:
<%flash.each do |name, msg|%>
<%= content_tag :div, msg, :id => “flash_#{name}”%>
<%end%>
- I have created custom methods for “inactive_message” and “active?”,
but the devise login form doesn’t appear to be using them. How can I
get devise to not log a user in when “active?” return false? The
documentation says it should… but it’s not working. What do I need
to enable to get this behaviour?
you have t override this 2 methods in the user model:
def active_for_authentication?
true
end
def inactive_message
:inactive
end
- For the registration page, I’d like to customize what the initial
object is - it’s a different subclass of the class knows about. I
don’t want to generate new controllers for this subclass just to get a
different registration page. How can do that? I also want to add yet
another registration page for a different user role - again, not
creating the rest of the controllers (they are not needed).
you only need to add the devise module in the model class and the
devise_for
in the routes, they both work together to help devise build the
corresponding authentication strategy and all that. you can add devise
and
the modules you want to use to your subclass and then add devise_for
subclass in the routes and it should work.
If these 3 questions mean I starting to push the bounds of what Devise
was designed to do, then I guess I’d also like to know that as well.
If I have to swap it out for a custom authentication system, it’s good
to know that 
not really, jose and carlos work hard to make devise very customizable
and
it keeps getting better and better, but if you ever come to a point
where
you need something very custom you should check authlogic.
Thank you very much for the reply Radhames Britto
I immediately tried your first 2 suggestions and they worked out
great. My suggestion for the #2 problem is to put this in the top-
level documentation on the github page (if you have the authority to
do that… or know the author and can tell him to do that). I would
think this is something at least 50% of the people will want to
customize. In my case, I just wanted to add a simple “is_enabled”
property and check against this - something very common.
Your suggestion worked great though. My problem was that I override
“active?” rather than “active_for_authentication?” -> and this is
actually not what the RDoc’s said
So that needs to be updated so
that others are not confused like me 
As for #3, I’m not sure I want to add devise_for in the routes. Maybe
I’m wrong here. I will explain what I want to do.
-
I want all of the routes exposed for all User models -> regardless
of subclasses and roles.
-
The only exception is that I want to a registration page for 2
specific subclasses -> all other roles are NOT to have a registration
page (they must be invited to the system by someone who is already
using it).
-
Each registration page is to be similar, but different. It would be
nice to have 2 different views, but I guess can use the same view and
have a bunch if “if this role, do this…” blocks. That might get
messy though… I’m not sure until I see what the resultant code looks
like.
So if I am to use devise routes… do I disable the registration page
for users, but add it for the other 2 roles while disabling all the
other pages?
I don’t want to duplicate views for all 3 roles… and I don’t want to
have 3 controllers instantiated that produce all of the same
functionality behind the scenes.
I hope I am making sense 
On Sat, May 21, 2011 at 1:37 AM, egervari [email protected]
wrote:
Your suggestion worked great though. My problem was that I override
“active?” rather than “active_for_authentication?” → and this is
actually not what the RDoc’s said
So that needs to be updated so
that others are not confused like me 
Be aware that the wiki at github is a wiki , that means it can be edited
by
any member of github and that is the case, i have contributed to the
wiki
and so can you, if there is something that confuses you or is inaccurate
you
can update the wiki if you have a github account. The best place for
accurate documentation is the source code at github, the wiki sometimes
lags
behind, is posible that at the time the wiki page where you read about
the
active? method was edited it was accurate but it no longer is, because
maybe
jose and/or carlos updated the source code.
Always inspect the source code of you favorite gems and try to understan
how
they work. Devise is no complex at all, is just a bit convoluted because
the
authors wanted to be posible to implemented on more than one model per
app
easily, that is devise can be mapped to any model by including the
devise
method in the model and devise for in the routes, and it will generate
the
rest of the MVC stack on the fly.