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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:44:27+00:00 2026-06-08T03:44:27+00:00

I have the following method in my ApplicationController so that I can load unique

  • 0

I have the following method in my ApplicationController so that I can load unique views depending on the user’s privileges. It works fine when I call it within the controller, but when I specify a partial I get the partial’s source instead of it rendering it.

class ApplicationController < ActionController::Base
  include ControllerAuthentication

  private

  def render(*args)
    options = args.extract_options!
    render_options = _normalize_render(*args)

    location = logged_in? && current_user.is_admin? ? "admin" : "client"

    options[:template] = "/#{location}/#{params[:controller]}/#{render_options[:action] || params[:action]}"

    if options[:partial]
      options[:partial] = "#{location}/#{params[:controller]}/#{options[:partial]}"
    end

    super(*(args << options))
  end
  helper_method :render

end

<%= render partial: "form" %> outputs something like this on the page.

["<form ...>...</form>"]

I’ve been reading through the source of the render method, but I haven’t pinpointed what is causing this. What do I need to change so I can render the partial correctly.

  • 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-08T03:44:28+00:00Added an answer on June 8, 2026 at 3:44 am

    The render method from AbstractController::Rendering has a different behaviour from the one defined in ActionView::Helpers. The fact you’re getting an array is normal since the rack stack expects and Enumerable for the body.

    With helper_method :render your overriding the implementation of the render method defined in ActionView::Helpers.

    I think it would be better to namespace your controllers and extract the common functionality (if any) in a module or a controller that will be used as a base controller for the specific implementation for each role.

    for example you could have something like:

    namespace :admin do
      resources :posts
    end
    
    namespace :client do
      resources :posts
    end
    

    the controllers for this will be located @

    app/controllers/admin/posts_controller.rb
    app/controllers/client/posts_controller.rb
    

    and the views

    app/views/admin/posts/...
    app/views/client/posts/...
    

    So basically you’ll gonna achieve the same effect but in a more railish manner, and this solves also the view problem.

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

Sidebar

Related Questions

I have following method which I am using to load ActiveX control dynamically, Dim
I have the following method that returns void and I need to use it
I have the following application_controller method: def current_account @current_account ||= Account.find_by_subdomain(request.subdomain) end Should I
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have the following method, which takes in the name of a file as
I have the following method where I want to test the event.status property only
I have the following method: public string Phase(string phase) { return Phase 1; }
I have the following method in my UIButton class: - (id)initWithCoder:(NSCoder *)aDecoder{ self =
I have the following method which is called when the value Edit Class... is
I have the following method: public static T ExecuteScalar<T>( string query, SqlConnection connection, params

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.