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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:45:56+00:00 2026-05-20T18:45:56+00:00

I am using Ruby on Rails 3 and I am trying to set an

  • 0

I am using Ruby on Rails 3 and I am trying to set an helper_method that should work just for a controller (example: AccountsController) and for all views related to that, also when its views are rendered in another views not related to that controller. I take inspiration from the Railcast “Restricting Access”.

In my accounts_controller.rb file I have

# Just to know, I am using a User namespace...
class Users::AccountsController < ApplicationController
  helper_method :show_authorization

  def show_authorization
    false # This returning value is just an example
  end
end

In my views/users/accounts/show.html.erb file I have

<% if show_authorization %>
  You are authorized!
<% else %>
  You are NOT authorized!
<% end %>

The above code works if I browse the URL http://<my_app_name>/users/accounts/1 but if I render the show.html.erb file as a template in another view file this way:

<%= render :template => "/users/accounts/show", :locals => { :account => @account } %>

I get the error:

NameError in Users#show 
undefined local variable or method `show_authorization' for #<#<Class:...>

Why? How can I solve that in order to make the AccountsController show_authorization method available to the show.html.erb view when that is rendered in another view related to another controller?

P.S.: Since the show_authorization is related only to the AccountsController and its views file, I would like to don’t insert the related code in the ‘application_controller.rb’ file but keep that in the ‘accounts_controller.rb’.

  • 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-20T18:45:57+00:00Added an answer on May 20, 2026 at 6:45 pm

    The helper_method is practically almost the same as a defining method in accounts_helper.rb (technically it eval code against helper class). In order to use this helper you need to define it in a helper module and include it in controllers where show template meant to be rendered.

    The actual problem is that different controller would know nothing about your accounts controller helpers until you explicitly require to include them.

    Examples:

    module Users::AccountsHelper
      code_here
    end
    
    class ApplicationHelper
      helper Users::AccountsHelper
    end
    

    all account helper methods will be available across application

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

Sidebar

Related Questions

I'm trying to tweak a behavior that I am seeing using Ruby on Rails
I am trying to set up Ruby on Rails on windows. I am using
I am using Ruby on Rails 3.0.7 and I am trying to set correctly
I'm new to programming and am trying to set up Ruby on Rails using
I am using Ruby on Rails 3 and I am trying to set values
I'm using Ruby on Rails 3.1 with mongoid and trying to set up som
I am using Ruby on Rails 3.0.9 and I am trying to set dynamically
Using Ruby on Rails. I'm trying to sort a query by number (saved as
I am trying to implement ruby on rails app using Capistrano, I am running
I am trying to learn Ruby on Rails using this Rails Tutorial. Earlier, I

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.