Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
4 Posts
Is Rails HMVC ?

From your diagram, it appears that what you call a helper might be an example of the Presenter pattern.

A Presenter acts as an intermediary between the View and the Model. Unlike the conventional Helper in Rails, the Presenter is object oriented in nature and can be used to aggregate several models into a single entity, which can be helpful if you're displaying several model instances or processing multiple form objects in a single controller action.

The Presenter pattern was never formalized into Rails, but rolling your own is no problem, and I've done this in several projects. Jay Fields has an old blog post that describes this pattern in some detail: http://blog.jayfields.com/2007/03/rails-presenter-pattern.html

Rails is an MVC framework i.e. it was designed to make building MVC applications easier.

You can write applications using Ruby on Rails without following this pattern - this would mean your application is not MVC, this wouldn't change MVC nature of Rails as a framework.

Can pattern you described be called HMVC? Call it whatever you want - you invented it! You just need to convince everybody to use this name (-:

But seriously, helper calls a model and renders a view... is that what you mean? This sounds like "components" (in general, not the deprecated Rails feature). Here's one implementation: http://cells.rubyforge.org/

Not that I like this idea - I somehow always found a nice way to do things MVC-way. Can you give an example where MVC is not feasible?

We know Rails follows MVC design pattern. If we consider independent partials which is rendered from a helper(it may call any model) method then rails will be cosidered HMVC?

Browser - Controller = Model
                  |                 View(Lets say it browser-calling helper method) - Helper(controller) = Model
                                                                   Independent Partial view

In the Figure above: With the same request from browser, if Helper(using model again) method is called(from view) which invokes rendering an independent partial file then entire this Rails system may be consider HMVC??

I am not sure.Please suggest me about this

Forum Rating: 100
Sign In To Rate Post
4 Posts
Login to add your message