model

Best way to send an email upon creation of a new model instance in Rails?

I have an app with the following models: User, Task, and Assignment. Each Assignment belongs_to a User and a Task (or in other words, a Task is assigned to a User via an Assignment). Once a User completes a Task, the Assignment is marked as complete, and the app immediately creates a new Assignment (or in other words, assigns the task t...

Return Object After Validation Failure

Is there a method to save an object but return the object if it fails the validation_uniqueness_of for a given field? For example, I have the following: class User has_many :words ... end class Word belongs_to :user validates_uniqueness_of :title ... end And I have a situation where I want to either return the Word object if...

Combined Data from 2 Domain Models

Hello everyone, im trying to implement the Data Gateway / Domain Pattern. I understand the basics and its a fantastic pattern to separate domain logic from the persistent data layer. Now i have following requirement: Lets say i have 2 domain-models: User(s) and Company(ies). When i wanna retrieve a user list with all users, i would do ...

CakePHP Relationship Question

I am trying to configure CakePHP to act as a REST API for an app i'm writing. I have 3 tables: dishes { id, name, description } users { id, name, email } dishes_users { id, user_id, dish_id } I would like it so that when someone visits /users/1.xml, the data that gets returns is just the list of 'dishes' that a user has in...

what is the difference between small memory model and large memory model ?

what difference does it make when i choose 'large memory model' instead of 'small memory model' inside Turbo C compiler ? how does that change behavior of my program ? regards, essbeev. ...

How to optimize image processing in Symfony from model

Hello, guys! Assume a Doctrine model Profile: # This is example of my schema.yml Profile: columns: avatar: type: string(255) notnull: true My goal is to generate profile's avatar from uploaded file: class Avatar extends BaseAvatar{ public function postSave($e){ if($this->getAvatar()){ // resize/crop it to 1...

Rails - Should an object's types be in its own model?

I have a contact, and contact has_many :phones. The phones table has a column named, phones_desc, where I want to include the type of phone number the user has saved. My question / Best practice Should I provide a select with manually provided options (such as "mobile", "work", "home")... -or- ...create a new model named phones_type...

Modeling a Join Table

Hi, I have the following database model: [User] Id Name [Role] Id Name [UserRole] UserId RoleId IsActive And I want to create a nice way to represent this relationship and the property that is in it with objects without creating a class to represent UserRole table. Any ideas? Thanks a lot! ...

How can my django model DateField add 30 days to the provided value ?

Hay guys, as the title suggests. I want to add 30 days to the DateField field. This is auto populated on creation of record using auto_now_add=True Any ideas how to go about doing this? Thanks ...

CodeIgniter - Model loaded but can't be used?

Ok. So I am working on a website using CI. Here is the structure of my controller: class MY_Controller extends Controller class User extends MY_Controller class User_Model So, I load the User_Model inside the constructor of the User controller. I know that it is loaded properly because I tried to print something from User_Model and it ...

Ruby On Rails ORM Model Relations

I'm a bit confused as to how "relationships" are created/processed in ROR/rake. Can anyone confirm if the following is correct? Code the "insert xxx relation" in the DB Migration file. Migrate this once done. Code in the final relationship (has_xxx...) in the model file. If so, can ROR autogen the DB Migration file from changes in t...

moving a function out of my method in django

Hay i have a method in my view which uploads an image, the image is then saved to a db object. I want to remove this from my view and either put it in my model or a seperate file. filename_bits = request.FILES['image'].name.split(".") filename_bits.reverse() extension = filename_bits[0] # create filename and open a destination filename...

[openGL] drawing a pipe that passes a given array of 3D-points

I have as input an array of 3D points. And I need to draw a pipe that connects those points with each other so the first point is connected to the second one, the second to the third, ... The pipe has a square-shape (not a cilinder, but more a cuboid-shape like this figure) with a width of d. And the difference between two points goes al...

What is the Best Workflow for Web Application?

I am about to begin a web application. Before I begin, I would like to get some advice as to what the best work flow/order is for creating a web application such as this. My project will consist of a server-side with PHP and MySQL. The client-side will be XHtml, CSS and jQuery. There will also be AJAX used. I'm sure that it can depend...

cake php use of table relations

Whats the usage of creation relations like var $belongsTo = array( 'UserType' => array( 'className' => 'UserType', 'foreignKey' => 'user_type_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); //The Associations below have been created with al...

How to programatically merge & render 3d models?

Hi All, I want to write an application that let users customize some 3d objects, making new objects by combining existing ones. For example, if a user wants to change just the roof of a house, he should select a new one (other existing roof object) and the whole model (the whole house) would be updated. I haven´t found any way to do th...

django new field generating "global name...is not defined" error

Hello, In a django app, I have models for a Word (to be learned), a Student (learning it), and StudentWord is a table to handle the many to many relationship: class Word(models.Model): word = models.CharField(max_length=80) image = models.ForeignKey(Image) language = models.ForeignKey(Language) def __unicode__(self): ...

how to change a model safe attributes in yii

hello, I have a CActiveRecord model, and I need to change safe attributes list in that model. I have defined the safeAttributes method inside my model, like the following : public function safeAttributes() { return array( 'name, bio', ); } the problem is 'bio' is not being considered in my safe attribute assign. I tried t...

Object wont update

Hay all, my object doesnt seem to update when i call the save() method heres my code car = Car.objects.get(pk=car_id) car.views += 1 car.save() and the model views = models.FloatField(max_length=1000) I do have a save() override method, could this cause a problem? def save(self): d = timedelta(days=self.expires_in...

Google vs. Yahoo; Software process model

Does any one knows which software process models are used by Google and Yahoo. And What is the difference in Yahoo and Google's software processes? Thanks & Regards, Jay ...