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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:50:30+00:00 2026-06-10T01:50:30+00:00

Suddenly I started getting this error while submitting a form. The only change I

  • 0

Suddenly I started getting this error while submitting a form. The only change I made is calling a method defined in ApplicationController which is marked as helper.

app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery

  helper_method :is_org_admin?

  #Check if current user is Admin in current organization or not
  def is_org_admin?
    session[:current_organization].is_admin?(current_user)
  end
end

is_admin? is defined as

class Organization < ActiveRecord::Base
  has_many :memberships
  has_many :users, through: :memberships

  def is_admin?(user)
    member = memberships.where(user_id: user.id).first
    if member.nil?
      false
    else
      member.is_admin?
    end
  end
end

And is_org_admin? method is being called from view template

app/views/users/index.html.haml

 %h1 Users
    - if is_org_admin?
      %p= link_to 'Invite new user', new_invitation_path

If I remove protect_from_forgery in ApplicationController or call to helper method if is_org_admin? in index.html.haml it works. But as I enable protect_from_forgery or the condition which calls helper defined in ApplicationController, it gives the warning and shows You need to sign in or sign up before continuing message on the page.

Would anyone please suggest what is the problem here?

  • 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-10T01:50:32+00:00Added an answer on June 10, 2026 at 1:50 am

    Instead of saving entire Organization model, I am saving it’s id in session to have instance of current organization. So as required, I search it on the fly.

    Organization.find(session[:current_organization_id]).is_admin?(current_user)
    

    Still I wonder why it returns 401 if organization AR saved and used from session.

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

Sidebar

Related Questions

I just suddenly started getting this error when trying to query the table AVC.
I suddenly started getting this error when trying to connect to any of my
Suddenly I started getting the following error: Fatal error: Class 'Mongo' not found in
I have suddenly started seeing this strange error when trying to push my database
I suddenly started to get this error. I don't know how to diagnose or
I suddenly started getting the following error in the General ouput window of Visual
I've been working on this Solution for a while now, but suddenly I'm getting
I suddenly started encountering this error out of no where and need some help.
One of our applications is started suddenly terminate with error Can't load file or
I suddenly have an error in my Android eclipse project. This is after a

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.