Hello there, I'm little confused about the MVC, I don't really know how to use it, as I understand the controller are used for events, and the view is what the visitor will see, and the model where you assign the variables which view would use? Is this correct? If yes, then why do I validate things in Model (below)? isn't this a event which should be in the controller? def validate errors.add(:username, "must not be john") if username == "john" end I hope someone can give me a link or anything to understand where things should be (MVC)? Thanks for any little help :) //Jamal
on 2007-02-16 18:53
on 2007-02-16 19:22
> errors.add(:username, "must not be john") if username == "john" > end > > I hope someone can give me a link or anything to understand where things > should be (MVC)? This is how I think of things... Models - this is lower level business logic that is applied to well, your models. So if you want to enforce that your Person model has a middle initial, this is the place to do it because to interact with Person's you *have* to go through the model to do it. So, regardless of whether the request is coming in from the website, an email, or script/console you can enforce rules here. Controller - this is higher level and really only relevant as far as your website is concerned. So this is where the logic goes to say display a Person and setup any other variables you want to display in your view. View - this is displayed to the end user and has the variables created in the controller available to it.