Are view models used in rails?
Posted
by Valentin Vasilyev
on Stack Overflow
See other posts from Stack Overflow
or by Valentin Vasilyev
Published on 2010-03-26T06:44:22Z
Indexed on
2010/03/26
6:53 UTC
Read the original article
Hit count: 277
ruby-on-rails
|asp.net-mvc
I'm starting to develop a small application in ruby on rails and many questions arise. I should say that I have about 1 year of experience with ASP.NET MVC and feel at home with models views and controllers. I've been using view models extensively (with the help of AutoMapper) and now wondering if view models are used similarly in rails camp.
From various examples (rails casts mainly) I've gathered that it is common to either combine data from multiple models right in your view (which is frowned upon in ASP.NET MVC), or to use virtual attributes on models to obtain "missing" data.
I know that business model should not be modelled after UI needs, for example there should not be a 'password confirm' property in your model, this should be a view model property.
Rails virtual properties seem to violate this principle.
How is it done in rails?
Thanks.
© Stack Overflow or respective owner