require admin to activate account before sign in

37 views
Skip to first unread message

matthew keable

unread,
Jul 18, 2016, 1:24:23 AM7/18/16
to Devise
Hey everyone, 

I'm having a difficult time getting this to work. The guide I'm following covers most of the material, but I feel like there are a couple omissions. One being the controller:
User.find_by_approved(false)
...which results in a NoMethodError and undefined method "each" when I click the link_to "Users awaiting approval".

Two: the provided controller method includes no way of actually approving users. Which should require another admin accessible controller function - but for update. RIght?

Walter Lee Davis

unread,
Jul 18, 2016, 7:34:33 AM7/18/16
to plataforma...@googlegroups.com

> On Jul 18, 2016, at 1:24 AM, matthew keable <matthew....@gmail.com> wrote:
>
> Hey everyone,
>
> I'm having a difficult time getting this to work. The guide I'm following covers most of the material, but I feel like there are a couple omissions. One being the controller:
> User.find_by_approved(false)
> ...which results in a NoMethodError and undefined method "each" when I click the link_to "Users awaiting approval".

It sounds to me like you expected a collection of unapproved users, but any of the find_ methods return a single record. Try changing this to where(approved: false), which will probably do what you want.

>
> Two: the provided controller method includes no way of actually approving users. Which should require another admin accessible controller function - but for update. Right?

Right. You will be approving a single record, so find it first (by its ID) and then update it.

Walter

>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Devise" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-de...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

matthew keable

unread,
Jul 18, 2016, 9:36:17 PM7/18/16
to Devise
That definitely solved it. So the find_by in the wiki example is only meant to show a single unapproved user? How strange. Thank you for your help!
> To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-devise+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages