model

Define "Validation in the Model"

There have been a couple of discussions regarding the location of user input validation: http://stackoverflow.com/questions/659950/should-validation-be-done-in-form-objects-or-the-model http://stackoverflow.com/questions/134388/where-do-you-do-your-validation-model-controller-or-view These discussions were quite old, so I wanted to as...

Can't send flash message from Model method

Hello, I'm trying to prevent a record that has a relationship to another record from being deleted. I can stop the deletion but not send a flash message as I had hoped! class Purchaseitem < ActiveRecord::Base before_destroy :check_if_ingredient ... def check_if_ingredient i = Ingredient.find(:all, :conditions => "purchaseite...

Find items with belongs_to associations in Rails?

Hi Everyone, I have a model called Kase each "Case" is assigned to a contact person via the following code: class Kase < ActiveRecord::Base validates_presence_of :jobno has_many :notes, :order => "created_at DESC" belongs_to :company # foreign key: company_id belongs_to :person # foreign key in join table belongs_to :survey...

Rails: Changes to object won't stick

I have a model called a voip_phone that has a an attribute schedule which is a string that keeps track of which people are using the phone at what time. Here's an example of a schedule: "mon{}sun{}sat{}tue{13,08:45,15:15;}wed{13,09:00,17:30;}thu{}fri{}" Here is the model code that won't work: def add_shift(days, person_id, time_f...

PHP database class pattern questions/suggestions

I am developing my own class model for my database and I would like to know what you guys think of it. For each table in my database I have 2 classes. The first one, is a fetching class (I don't know how to call it..), this class has some static methods interacting with the database (fetchAll, fetchById etc..). The second class is the m...

KindError: Property r must be an instance of SecondModel, why ?

class FirstModel(db.Model): p = db.StringProperty() r=db.ReferenceProperty(SecondModel) class SecondModel(db.Model): r = db.ReferenceProperty(FirstModel) class sss(webapp.RequestHandler): def get(self): a=FirstModel() a.p='sss' a.put() b=SecondModel() b.r=a b.put() a.r=b a.put() self.r...

How can I create a horizontal table in a single foreach loop in MVC?

Is there any way, in ASP.Net MVC, to condense the following code to a single foreach loop? <table class="table"> <tr> <td> Name </td> <% foreach (var item in Model) { %> <td> <%= item.Name %> </td> <% } ...

how to create model based Acl

hello all if we have some modules in our application how we could create Model based ACL by zend framework for each models? thanks ...

Spring 3 Controllers - Maintaining Model Through Flow

I'm sure there is some way to accomplish what I'd like here, but I haven't been able to find it in the documentation import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping(value = "/test") public class TestControll...

MVC null model problem

hello, i have created two create actions..one to call the create view and the other to process the create view using httppost. when i call the create view, it gets published correctly , dropdowns and all. the problem is that when i fill out the create form and click on the submit button, i get an error; Object reference not set to an ...

Why is this an endless loop? ActiveRecord

class Account < ActiveRecord::Base after_update :give_user_credit, :on => :update def give_user_credit credit = User.current_user.credit + 3.8 User.current_user.update_attribute(:credit, credit) end end When I use this the server hangs and when I come back to the application after a full reboot my credit is in the £1000...

how to import the parent model on gae-python

main:. ├─a │ ├─__init__.py │ └─aa.py ├─b │ ├─__init__.py │ └─bb.py └─cc.py if i am in aa.py , how to import cc.py ? this is my code ,but it is error : from main import cc what should i do . thanks updated in normal python file (not on gae),i can use this code : import os,sys dirname=os.path.dirname path=os.path....

App Engine: how would you... snapshotting entities

Let's say you have two kinds, Message and Contact, related by a db.ListProperty of keys on Message. A user creates a message, adds some contacts as recipients, and emails the message. Later, the user deletes one of the contact entities that was a recipient of the message. Our application should delete the appropriate Contact enti...

When to use Doctrine_Table vs regular model class?

I'm trying to understand when is the appropriate time to use Doctine_Table classes and which methods to store there vs. in the regular model class file. Also, is it good practice to use the findBy* methods? ...

Doctrine - best way to check for a record, then either update or add

I've come across this scenario a few times in working on a current project. I have to see if a record exists then if it doesn't I need to add it, if it does then I need to update. What is the standard way of doing this with Doctrine? I seem to be querying to see if the record exists using a find* method. Then if that returns a positive ...

How to read a Choice Field from Sharepoint 2010 Client Object Model

Hello, I'm using Sharepoint 2010 Object Model. I'm trying to retrive the content of a Custom List. Everything works fine except if when I try to retrieve a Choice Field. When I try to retrieve the choice field, I got an PropertyOrFieldNotInitializedException exception... Here is the code I'm using: ClientContext clientCon...

DDD and MVC: Difference between 'Model' and 'Entity'

I'm seriously confused about the concept of the 'Model' in MVC. Most frameworks that exist today put the Model between the Controller and the database, and the Model almost acts like a database abstraction layer. The concept of 'Fat Model Skinny Controller' is lost as the Controller starts doing more and more logic. In DDD, there is a...

Formating a date field in the Model (Codeigniter)

Hi, I', trying to re-format a date from a table in Codeigniter. The Controller is for a blog. I was succesfull when the date conversion happens in the View. I was hoping to convert the date in the Model to have things in order. This is the Model: class Novedades_model extends Model { function getAll() { $this->db->order_by('da...

how can i generate a diagram from a rails project ?

i am trying to generate a rails diagram from a project with railroad. but i am getting a railroad: command not found even after installing the plugin : sudo gem install roadrail what is the problem? is there an alternative to that plugin? thank you for you help ...

How Do I Import a 3D Object into Adobe Flex?

Hi everyone, I wanted to know if anyone here knows how to import a 3D Object (i.e. Maya 3D Model) into Adobe Flex Application? I needed to create a simple Flex application which will allow me to rotate the 3D Object by dragging but I cannot seem to start doing it because I'm having a hard time trying to figure out how I can import my 3D...