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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:00:50+00:00 2026-05-23T00:00:50+00:00

As the application grows, I’m starting to use a Presenter Pattern similar to what’s

  • 0

As the application grows, I’m starting to use a Presenter Pattern similar to what’s outlined here:

http://blog.jayfields.com/2007/03/rails-presenter-pattern.html

I would like the presenter to be able to access the same scope of the controller it’s in, in a way that minimally impacts application performance, and that has a clear API. Something like this:

class UsersController < ApplicationController
  def index
    @view = UsersPresenter.new(self)
  end
end

class Presenter
  def initialize(controller)

  end
end

class UsersPresenter < Presenter

end

I could use method_missing to access methods on the controller but that comes at a performance cost, and would probably be confusing to debug:

class Presenter
  attr_reader :controller

  def initialize(controller)
    @controller = controller
  end

  def method_missing(method, *args, &block)
    controller.send(method, *args, &block)
  end
end

I would like it to work just like a module, but without being a module so I don’t clutter the global controller namespace.

Any ideas what’s best here? Maybe the delegate method?

Thanks for the tips.

  • 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-23T00:00:51+00:00Added an answer on May 23, 2026 at 12:00 am

    An approach to work around method_missing: Enumerate all instance methods of the controller and define methods in the eigenclass of your presenter (in the initializer). However I doubt that it’s better performance-wise when compared to method_missing.

    Also this won’t work for methods that were added to the controller via method_missing (like polymorphic routes).

    I don’t think that you can work around the method_missing completely if you want access to all the (missing) methods of the controller without explicitly writing controller.some_method in your presenter.

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

Sidebar

Related Questions

I need to use a text-box (multiline) in my application. It need to grow
I am setting up a location aware application, as mentioned here . I have
Since our application grows, we need more space on our Windows CE devices. We
What does one do when the number of buttons in an application grows beyond
My application similar to hypotetical program: for(;;) { for (i=0; i<1000; i++) { p[i]
I currently have an application in Mac Os X whose Real Memory footprint grows
I started programming with MVC3 without any knowledge of areas. As the application grows
I have written a mapping application which can either use Google Maps or Open
My client-server application is mainly based on special purpose http server that communicates with
We have a D2007 application whose memory footprint grows steadily when running on Windows

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.