Is it valid to include view code in Model?

Posted by Shreekumar S on Stack Overflow See other posts from Stack Overflow or by Shreekumar S
Published on 2012-04-09T05:11:14Z Indexed on 2012/04/09 5:28 UTC
Read the original article Hit count: 136

Filed under:
|
|
|
|

Guys I'm new to RoR and MVC.

I've a model which deals with loan beneficiary's data. To access the structured data (including small piece of HTML data) I created a method like this

class Beneficiary  < ActiveRecord::Base
  def  info
     "#{name}</br>#{age},#{sex}</br><b>Address :</b>#{address}"
  end
end

And in the view, I'm using this info something like this

<%= @b.info.html_safe %>

were, b is an instance of Beneficiary class

It's working fine for me. I just want to know that, Am i violating the MVC rule here? Is it valid to include view code in Model?

© Stack Overflow or respective owner

Related posts about html

Related posts about ruby-on-rails