Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8525591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:01:32+00:00 2026-06-11T08:01:32+00:00

Rails 3.0 Following these instructions: https://github.com/plataformatec/devise/wiki/How-To%3a-Require-admin-to-activate-account-before-sign_in I’ve generated a migration :approved (boolean) for my

  • 0

Rails 3.0
Following these instructions:
https://github.com/plataformatec/devise/wiki/How-To%3a-Require-admin-to-activate-account-before-sign_in
I’ve generated a migration :approved (boolean) for my devise user.rb. Now I want to edit it with a checkbox from a different controller: unapproved_users_controller.rb.
When I load the form in the edit I get this error: undefined method `user_path’.

routes.rb, the resources for my new controller

resources :unapproved_users 

app/models/user.rb, notice that :approved is attr_accessible.

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  attr_accessible :email, :password, :password_confirmation, :remember_me, :approved

  def active_for_authentication? 
    super && approved? 
  end 

  def inactive_message 
    if !approved? 
      :not_approved 
    else 
      super # Use whatever other message 
    end 
  end

  def self.send_reset_password_instructions(attributes={})
    recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
    if !recoverable.approved?
      recoverable.errors[:base] << I18n.t("devise.failure.not_approved")
    elsif recoverable.persisted?
      recoverable.send_reset_password_instructions
    end
    recoverable
  end
end

app/controllers/unapproved_controllers.rb

class UnapprovedUsersController < ApplicationController

  def index
    if params[:approved] == "false"
      @users = User.find_all_by_approved(false)
    else
      @users = User.all
    end
  end

  def edit
    @user = User.find(params[:id])
  end

  def update
    @user = User.find(params[:id])
    @user.update_attributes(params[:user])
  end  

end

app/views/unapproved_users/index.html.haml

%h1 Users

= link_to "All Users", :action => "index"
|
= link_to "Users awaiting approval", :action => "index", :approved => "false"

%table
    - @users.each do |user|
        %tr
            %td= user.email
            %td= user.approved
            %td= link_to "Edit", edit_unapproved_user_path(user)

app/views/unapproved_users/edit.html.haml

= render 'form'

app/views/unapproved_users/_form.html.haml

= form_for (@user) do |f|

  -if @user.errors.any?
    #error_explanation
      %h2= "#{pluralize(@user.errors.count, "error")} prohibited this user from being saved:"
      %ul
        - @user.errors.full_messages.each do |msg|
          %li= msg

  .field
    = f.label :approved, 'Approved?'
    = f.check_box :approved 
  .actions
    = f.submit 'Save'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:01:34+00:00Added an answer on June 11, 2026 at 8:01 am

    You need to change the form_for.

    It should be

    = form_for(@user, :url => unapproved_user_path(@user)) do |f|
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was able to setup Virtualbox with Gitlab using these instructions --> https://github.com/gitlabhq/gitlabhq/wiki/VirtualBox-Image .
Following these instructions http://robertogds.com/post/3324511589/howto-backbone-js-using-rails-3 The issue/error is that the content is never saved to
I am trying to install this plugin for my rails app: https://github.com/remvee/unobtrusive_upload_progress In the
Following instructions from http://web2linux.com/installing-rails-3-on-ubuntu-10-04-lucid-lynx/ I get to the following line: rvm install 1.9.2 returns:
I set up a new Rails application by following these instructions . I generated
The following url is formed in my rails application, http://example.com/filter/filters?binding_id=1>1&escape=false&filter_type=publisher_id&from_pagination=0&genre_id=0>57&order=3&page=8&publisher_id=3>160&query=books&search_case=products&sub_category_id=1&tree_filter_id=115&utf8=%E2%9C%93&view_name=generic2d4e4c5333133cd814a2cb102571e4dc Is this OK? If
I'm using rails 3.1 with Devise. When an account confirmation email goes out, it
I followed these instructions to set up basic LDAP authentication via Devise in my
After upgrading to Rails 3.1.0 and following David Rice's instructions , all of my
I have the following rails code in a loop that has a link for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.