Part of the MVC pattern, the Model manages the behavior and data of the application.
136
votes
5answers
17k views
How should a model be structured in MVC?
I am just getting a grasp on the MVC framework and often I wonder how much code should go in the model. I trend of have a data access class that has methods like this:
public function ...
100
votes
11answers
17k views
Doctrine2: Best way to handle many-to-many with extra columns in reference table
I'm wondering what's the best, the cleanest and the most simply way to work with many-to-many relations in Doctrine2.
Let's assume that we've got an album like Master of Puppets by Metallica with ...
54
votes
14answers
16k views
Is there a way to get a collection of all the Models in your Rails app?
Is there a way that you can get a collection of all of the Models in your Rails app?
Basically, can I do the likes of: -
Models.each do |model|
puts model.class.name
end
Thanks in advance.
8
votes
2answers
10k views
Real example of TryUpdateModel, ASP .NET MVC 3
I can't understand, how to use TryUpdateModel and save the MVC architecture at the same time.
If I am not mistaken, work with datacontexts must be in the Model. So, such code
var db=new ...
39
votes
4answers
7k views
Fat models, skinny controllers and the MVC design pattern
I just read a blog post that explains MVC with a banking analogy. I have a few months of experience with web application development with an MVC framework (CakePHP), so I get the basics, but I began ...
60
votes
1answer
40k views
Django set default form values
I have a Model as follows
class TankJournal(models.Model):
user = models.ForeignKey(User)
tank = models.ForeignKey(TankProfile)
ts = models.IntegerField(max_length=15)
title = ...
86
votes
2answers
30k views
Rails find_or_create by more than one attribute?
There is a handy dynamic attribute in active-record called find_or_create_by:
Model.find_or_create_by_<attribute>(:<attribute> => "")
But what if I need to find_or_create by more than ...
23
votes
5answers
10k views
Rails Model has_many with multiple foreign_keys
Relatively new to rails and trying to model a very simple family "tree" with a single Person model that has a name, gender, father_id and mother_id (2 parents). Below is basically what I want to do, ...
12
votes
3answers
7k views
Why Two Classes, View Model and Domain Model?
I know it could be bad to use domain models as view models. If my domain model has a property named IsAdmin and I have a Create controller action to create users, someone could alter my form and get ...
3
votes
2answers
8k views
How to find iPhone/iPod Device model(3G,3GS,4,4S) by code? [duplicate]
Possible Duplicate:
Determine device (iPhone, iPod Touch) with iPhone SDK
I have tried to get the current device model name like 3G,3GS,4,4S,iPodTouch(Different Generations). But, i cant ...
2
votes
4answers
896 views
How to change the sequence of 'joins' in CakePHP?
I have the problem with the sequence of joins. The similar problem was in another question http://stackoverflow.com/questions/3343348/manipulating-order-of-joins-in-cakephp. The answer was to use ...
52
votes
2answers
23k views
Rails :dependent => :destroy VS :dependent => :delete_all
In rails guides it's described like this:
Objects will be in addition destroyed if they’re associated with :dependent => :destroy, and deleted if they’re associated with :dependent => ...
5
votes
1answer
5k views
Model binding with nested child models and PartialViews in ASP.NET MVC
I have the following types and classes:
{
namespace MVC.Models
public class Page
{
public EditableContent Content {get; set; }
}
public class EditableContent
...
17
votes
5answers
10k views
Modeling objects with multiple table relationships in Zend Framework
I'm toying with Zend Framework and trying to use the "QuickStart" guide against a website I'm making just to see how the process would work. Forgive me if this answer is obvious, hopefully someone ...
13
votes
4answers
11k views
Rails has_many with dynamic conditions
What I want is to create a Model that connects with another using a has_many association in a dynamic way, without the foreign key like this:
has_many :faixas_aliquotas, :class_name => ...