0

I have a small question about collection_select in Rails 4. When we call in the collection_select all the elements of a table example:

<%= f.collection_select :category_id, Category.all, :id, :name %>

Is MVC violated? In other words: if I have a collection_select in the view of products and it calls Category.all in this view, for me we are violated the MVC pattern. Cause Category.all is something that should be in a Model.

Tell me if I'm in right.

4

1 回答 1

0

Passing a collection to collection_select as a list of options is not a violation of MVC pattern, it's just how collection_select is seeded with data.

于 2015-05-14T19:26:26.720 回答