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 713575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:58:36+00:00 2026-05-14T04:58:36+00:00

I am trying to block all default methods except create and update in my

  • 0

I am trying to block all default methods except create and update in my users controller using declerative_authorization. But at the time I add filter_resource_access or filter_access_to into my usersController i always get “Couldn’t find User without an ID”. Anyone care to explain why this could be happening?

    class UsersController < ApplicationController
  filter_resource_access

def new @user = User.new end

def create @user = User.new(params[:user]) if @user.save flash[:notice] = "Account registered!" redirect_to account_url else render :action => :new end end

def show @user = @current_user end

def edit @user = @current_user end

def update @user = @current_user # makes our views "cleaner" and more consistent if @user.update_attributes(params[:user]) flash[:notice] = "Account updated!" redirect_to account_url else render :action => :edit end end end

  • 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-05-14T04:58:36+00:00Added an answer on May 14, 2026 at 4:58 am

    You should set the @user variable before the filter_access_to call with a before_filter as declarative_authorization tries to access @user when you call filter_access_to.

    before_filter :set_user
    filter_access_to :all
    
    ...
    
    protected
    
    def set_user
      @user = @current_user
    end
    

    Maybe you are setting the attribute_check parameter to true in your filter_access_to call? I have a similar controller and I don’t really need the before_filter.

    Another thing that might be causing it is a using_access_control call in your User model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set up mod proxy to block all traffic except to a
I am trying to block click on links using jQuery blockUI plugin. It's seems
I am trying to code AES using Cipher Block Chaining(CBC) mode. I am pretty
I am trying to add a page that extends my default layout. I put
I am trying to set some default values for an object using after_initialize .
I'm trying to add some opacity to a part of a website while using
I am trying to create some methods that should make it easier to perform
Help with regular expressions needed. I'm trying using regular expressions and preg_match_all find blocks
I am trying to block the background with my two jquery modal dialogs until
I'm trying to block viewing a javascript page (.js) if user is not logged

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.