Tag Info

New answers tagged

2

This is an ancient debate really. It goes all the way back to the first databases and the notion of "referential integrity", which in turn is a variation of the strong-typing / weak-typing debate. Who's job is it to make sure that data is stored in a consistent and "known good" manner? MVC purists will tell you it's the controller's job. Database ...


0

If you only want to check that the name exists, yes it belongs to the model. From wikipedia: A controller can send commands to the model to update the model's state (e.g., editing a document). It can also send commands to its associated view to change the view's presentation of the model You are not doing any of those. You are checking if the ...


0

A code example would help, but in rails, validations belong in the model. Check out validates_inclusion_of. Also, you should be aware that models dont nescessarily have to be backed by persistence. There are lots of times when it's appropriate to use plain ruby objects. In general, its best to keep as much functionality out of the controller as possible, ...


1

Take maxims such as "thy model shall only care about the database stuff" with a grain of salt. Dogma has no place in engineering. In order to answer this question you need to first understand the nature of this validation array, and whether it fits conceptually with the model or with controlling the model. The fact that these names are stored inside ...


-1

IMHO and in my understanding, You are validating the data from the given array, not from the database. So I strongly believe you should do it in the controller. the general rule of thumb is to only write database interactions inside model.



Top 50 recent answers are included