Is it okay to call a model method in my view?
In the interest of keeping my Controller's skinny, I put a headline method in a Model.
# My Model
class Property
def headline
"#{name} | #{address}"
end
end
(Then, Property Controller for context...)
# My Controller
class PropertyController
def show
@property = Property.find(params[:id])
end
end
Question: As far as MVC is concerned, is it okay to call that Model method from my View, like so?
# My View
<h1><%= @property.headline %></h1>
In the interest of keeping my Controller's skinny, I put a headline method in a Model.
# My Model
class Property
def headline
"#{name} | #{address}"
end
end
(Then, Property Controller for context...)
# My Controller
class PropertyController
def show
@property = Property.find(params[:id])
end
end
Question: As far as MVC is concerned, is it okay to call that Model method from my View, like so?
# My View
<h1><%= @property.headline %></h1>
No comments:
Post a Comment