model-view-controller

In ideal MVC should the view know the model?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-02 03:34:28
问题 My question is about the ideal or the original MVC interpretation http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html As MVC goal is to reduce dependencies, should the View knows the Model ? Then what would prevent it to become fat and call directly Model Methods without asking Controller ? Update: as I read answer below, I'll take a concrete example: Let's say you create a complex calculator (not just some simple one let's say an option pricer for stock market). It only needs input

superclass mismatch for class CommentsController (TypeError), best way to rename?

家住魔仙堡 提交于 2020-01-02 01:41:11
问题 I ran into some problem tonight while deploying and I'm trying to get this fixed asap I have no idea why this is happening. Everything works fine locally but not on heroku. I tried all sorts of different fixes after researching but I may have to resort to renaming this class CommentsController completely (hopefully that works). What is the best way to go about that? I'm pretty new to Rails so I need some help on making these changing correctly. Here's what the CommentsController looks like

Mvc3 web app routing directly on index.cshtml

旧巷老猫 提交于 2020-01-01 17:37:26
问题 I have created and host nvc3 web app now problem is when I open my www.abc.com it is opening index.cshtml i.e home page of mvc web app but I dont want that to be open when I open www.abc.com I have one static page called index.htm should be open first in mvc3 Global.asax code: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new {

Some uncertainty with implementing the 3 structure Model (Domain object, data mapper and service)

删除回忆录丶 提交于 2020-01-01 14:23:15
问题 As the heading suggests I am having some small problems while implementing the 3 structure Model (Domain object, data mapper and service). In the past when someone was registering on my site I would simply do $user->register($firstName, $lastName, $emailAddress, $username...); and that method would run in steps like this 1. Check if the form sent was valid. 2. Check if all the required fields were filled. 3. Check the if the lengths of strings were valid and the range of integers etc. 4.

Some uncertainty with implementing the 3 structure Model (Domain object, data mapper and service)

自古美人都是妖i 提交于 2020-01-01 14:22:15
问题 As the heading suggests I am having some small problems while implementing the 3 structure Model (Domain object, data mapper and service). In the past when someone was registering on my site I would simply do $user->register($firstName, $lastName, $emailAddress, $username...); and that method would run in steps like this 1. Check if the form sent was valid. 2. Check if all the required fields were filled. 3. Check the if the lengths of strings were valid and the range of integers etc. 4.

Nested model validation - errors don't show

吃可爱长大的小学妹 提交于 2020-01-01 11:55:15
问题 There have been many questions about this, but none of them seem to help. And yes, I have watched this rails cast. I have an Author who has many Books, like so: Author: class Author < ActiveRecord::Base attr_accessible :name has_many :books, dependent: :destroy accepts_nested_attributes_for :books, allow_destroy: true validates :name, presence: true validates :name, length: { minimum: 3 } end Book: class Book < ActiveRecord::Base attr_accessible :name, :year belongs_to :author validates :name

Where to put validation logic in MVC software architecture

老子叫甜甜 提交于 2020-01-01 11:48:12
问题 I am actually starting to learn the mvc architecture. I'm confused on whether to place my username registration validation logic in model or in controller. I have some sort of status message that would tell the user whether the new username to register is available or not. My confusion started because most sources say that it should be in the model because it involves the username data to validate before placing it on the database (rather than checking inputs to the username field). However,

Codeigniter 3.0.0 - error 404 page not found

五迷三道 提交于 2020-01-01 11:42:13
问题 This is my first php framework. I have a php file in my controller which is posts.php but when I tried to run it localhost/codeigniter/index.php/posts, it displays error 404 .htaccess inside application folder <IfModule authz_core_module> Require all denied </IfModule> <IfModule !authz_core_module> Deny from all </IfModule> autoload.php $autoload['libraries'] = array('database'); $autoload['helper'] = array('url'); config.php $config['base_url'] = 'http://localhost/codeigniter/'; $config[

zend-framework doctrine, and mvc pattern: what kind of layer should connect data between models and forms?

房东的猫 提交于 2020-01-01 10:48:08
问题 I am learning Zend Framework and Doctrine. I am wondering what is the best practice to connect forms to models and vice versa. In some cases it is handy to load data from model in form class. Lets say a very unique class which use many models. In other cases it is convenient to have methods in model class which prepares data for forms. Lets say it could have a method which returns an array prepared for select-options element, so this method will be useful for many forms. I would like to have

AppDelegate or AppController

岁酱吖の 提交于 2020-01-01 10:02:47
问题 While reading cocoa tutorials i've noticed that some of the tutorials use AppDelegate and some AppController for defining IBActions that open various windows that use subclasses of NSWindowController . Is there some sort of rule of thumb for this? 回答1: It's just a class name. AppDelegate implies that the class's main duty is as NSApplication's delegate, whereas AppController seems to imply a broader range of responsibility. 回答2: I create one class that is solely my app delegate, and