OneChillDude
OneChillDude

Reputation: 8006

Rails - Is it terrible to call models directly in views?

So I have a search partial that I want to be able to use anywhere in the site. I realize that it's generally bad to put logic in the view, but can I do something like

= form_for User.search do |f|

Or is it an absolute semantic must that I put any kind of model-method call in the controller, even if I'm not modifying anything?

Upvotes: 0

Views: 78

Answers (1)

user710046
user710046

Reputation:

A better approach would be to use the presenter pattern my friend!

There's a great railscast about the Draper gem here

Hope that will steer you away from the potentially painful path you tread!

Upvotes: 1

Related Questions