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

  • Home
  • SEARCH
  • 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 6923671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:33:54+00:00 2026-05-27T10:33:54+00:00

There is a method has_edit_right? defined in customers_helper.rb file. The method needs to be

  • 0

There is a method has_edit_right? defined in customers_helper.rb file. The method needs to be accessed by both the controller and its view. The rspec returns NoMethodError:

  1) CustomersController GET customer page 'edit' should be successful if current user is the owner of the customer
     Failure/Error: post 'edit', :id => customer.id, :customer => {:name => "name changed"}
     NoMethodError:
       undefined method `has_edit_right?' for #<CustomersController:0x3df6980>
     # ./app/controllers/customers_controller.rb:40:in `edit'
     # ./spec/controllers/customers_controller_spec.rb:87:in `block (3 levels) in <top (required)>'

Any thoughts about the problem? Thanks.

  • 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-27T10:33:55+00:00Added an answer on May 27, 2026 at 10:33 am

    Helpers are for views, that’s their point. They aren’t supposed to be available in the controller, they’re specifically for distilling out reusable view logic. If you need a method available to both the controller and its views, define a protected method in the controller and provide it to the view via helper_method.

    In this example, the method has_edit_right? defined in the controller will also be available to the views.

    # app/controllers/posts_controller.rb
    
    class PostsController < ApplicationController
    
      helper_method :has_edit_right?
    
      # ...
    
      def edit
        raise "Access Denied" unless has_edit_right?
        # ...
      end
    
      protected
    
      def has_edit_right?
        current_user.admin?
      end
    end
    

    # app/views/posts/show.html.erb
    
    <% if has_edit_right? %>
      <%= link_to "Edit Post", edit_post_path(@post) %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C# is there a technique using reflection to determine if a method has
I've got following problem: (c#) There is some class (IRC bot), which has method,
Is there a standard library method that converts a string that has duration in
Has there been any attempt and creating a formalized method for organizing CSS code?
There was an Html.RadioButtonList extension method in ASP.NET MVC Futures. Has anyone found a
Is there a method of accessing an Exchange server that does not have IMAP
Is there a method to get all of the .aspx files in my website?
Is there any method? My computer is AMD64. ::std::string str; BOOL loadU(const wchar_t* lpszPathName,
Is there any method to generate MD5 hash of a string in Java?
is there a way to break out of the foreach extension method? The break

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.