Questions tagged [model]

Part of the MVC pattern, the Model manages the behaviour and data of the application.

The MVC (Model, View, Controller) pattern separates objects into one of three categories — models for maintaining data, views for displaying all or a portion of the data, and controllers for handling events that affect the model or view(s).

Frameworks such as Laravel, Rails, Django and ASP.NET MVC apply this pattern in the web development domain.

18996 questions
4
votes
2 answers

MVC3 Editor template doesn't generate client side validation

I have an issue, basically i have a form with lots of fields in it, and all of them have a required attribute set, so when you just leave it empty and click ok, you get client side validation and it becomes red. It words fine for everything exept…
Alnedru
  • 2,573
  • 9
  • 50
  • 88
4
votes
3 answers

Auto generate models classes in mvc from database

I heard that people use entity framework to generate model related classes from database. Suppose if I do not want to use entity framework as data access layer rather I want to use MS data application block so then how can I auto generate models…
Thomas
  • 33,544
  • 126
  • 357
  • 626
4
votes
1 answer

Yii multiple relations to same table

I have the following relations defined in my UserBan model: public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return…
Samson
  • 2,801
  • 7
  • 37
  • 55
4
votes
2 answers

Models not being saved in Play Framework

Assume a model named User: @Entity public class User extends Model { @Id @Constraints.Min(10) public Long id; @Constraints.Required public String username; @Constraints.Required public String password; public…
4
votes
1 answer

AngularJS: When user action impacts both the model and the DOM

This is for an AngularJS app. I have a custom directive that depends on a service. What I'm really curious about is the "angular way" to deal with a user action that impacts both model and DOM. Some example code: HTML:
BjornJohnson
  • 332
  • 1
  • 8
4
votes
1 answer

Files in domain model

What are the best practices for dealing with binaries in domain model? I frequently must associate images and other files with business objects and the simple byte[] is not adequate even for the simplest of cases. The files: Does not have a fixed…
Arunas
  • 918
  • 1
  • 8
  • 20
4
votes
2 answers

django polymorphic model, filter on subclass field

I have some models using django-polymorphic-model eg. class Article(PolymorphicModel): ... class Blog(Article): tags = ... class Story(Article): publish = ... Normally if I get all articles, I just do Article.objects.all(), however what if I…
James Lin
  • 25,028
  • 36
  • 133
  • 233
4
votes
2 answers

Handling circular data in Oracle's SQL

There is a problem that don't know how to resolve only with SQL (I could do it with PL/SQL, but it should be doable only with SQL). I have a table (in fact it's not a table but the result of a with query) with contains pair of values like this: …
Samuel
  • 2,430
  • 2
  • 19
  • 21
4
votes
2 answers

Selecting Rails Models via Virtual Attributes

I have the two rails models Section & SectionRevision. A Section is mostly just a container that holds all the Revisions relating to itself. So most of the attributes for the Section are basically stored within the SectionRevision model so there's a…
Ryan King
  • 3,538
  • 12
  • 48
  • 72
4
votes
1 answer

Can't set Default Values For Number and String Types in Ember Models

I'm trying to set default types in an Ember Model, but only some types work: createdDate: DS.attr('date', {defaultValue: new Date()}) // Works createdDate: DS.attr('boolean', {defaultValue: false}) // Works createdDate: DS.attr('string',…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
4
votes
1 answer

How to synchronize Model and View Model bidirectional in MVVM?

It's a simple question and I searched the Internet for hours without success... I have a model and a view model with one property. To make this property viewable in the view, I use a view-model-object which should automatically be generated from the…
4
votes
1 answer

Adding some custom methods to delayed job in rails 3?

I want to add some custom methods to the delayed jobs model. I want to have some extra such as... def status return "errored" unless self.last_error.blank? return "waiting" if self.locked_at.blank? return "running" unless…
CafeHey
  • 5,699
  • 19
  • 82
  • 145
4
votes
4 answers

ASP.NET MVC 4: Skip Validation in Child Object

First of all, sorry about my English. Not my natural language. I have a class named Category like the code below. Note that in this code I also have a Category property, in which I can reference a father Category. It's just the same class declared…
Ricardo Pieper
  • 2,613
  • 3
  • 26
  • 40
4
votes
3 answers

Result Set Stored on Models - C# .NET 2.0

I have a function that gets the data in the database. Below are the code. public DataTable getAllTransaction(OleDbConnection conn) { OleDbDataAdapter oleAdapter = new OleDbDataAdapter(); string query = ""; …
Bryan
  • 1,245
  • 5
  • 22
  • 37
4
votes
2 answers

Bound activerecords-queries using aggregate funcs (sum, avg,...) with limit

Given this pseudo-query: Model.sum(:column, :condition => ['id = ?', id], order => "date DESC", :limit => X) Here we have the problem that the sum obtained is not "limited" by the value X (it takes as sum all values on the column instead that the…
damoiser
  • 6,058
  • 3
  • 40
  • 66