> No. It *is* the controller's job to trigger render operations. There's
> nothing un-MVC about this at all.
Sure it's a controller's job to trigger render operations. But
render :update is a special kind of operation that generates
JavaScript in your action, and sometimes that JavaScript can contain
quite a bit of HTML. Does it 100% sound like a separation of Domain
logic and Presentation? I don't think so. But we should not be so
critical about this. Render :update construct provides you the same
ability as templates do but it's inline of the action - thus it's very
convenient.
It's more of a question of choosing the right tool to do your job! If
you want to be 100% sure that you don't break MVC, then put
render :update into the separate rjs template, this way you won't
waste time thinking if it breaks MVC or not and will focus on your
app. And it will also help you out if you need to put more page
updates into that block and it gets bigger. But I personally love
using render :update since it's so easy and transparent and fits
perfectly to quickly respond to AJAX call.
--
Thanks, Ivan Povalyukhin
On Dec 24, 8:38 am, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
> Colin Law wrote in post #970508:
>
> > On 24 December 2010 14:29, Marnen Laibow-Koser <li...@ruby-forum.com>
> > wrote:
> >> ivanpoval wrote in post #970446:
> >>> The code sample you provided is very common and many respectful Rails
> >>> developers use it.
> >>> If we go out of the scope of Rails and start speaking very strictly
> >>> about MVC, then probably we can say that it is not actually the
> >>> controller's job to do that type of things.
>
> >> No. It *is* the controller's job to trigger render operations. There's
> >> nothing un-MVC about this at all.
>
> > Is the fact that the controller is specifying that a particular div
> > should be updated ('my_div' in this case) a bit non-MVC?
>
> Good point! Yes, that might be. So is the fact that the controller
> contains literal RJS, but that's just the way to get it to contain a
> render :partial statement.
>
>
>
> > Colin
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
>
> Sent from my iPhone
>
> --
> Posted viahttp://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment