model

Order records from multiple models by attribute

Given the three models “message”, “profile” and “comment” i want to merge them into one list, ordered by their common attribute “created_at”. I want to accomplish something like the project overview in Basecamp - see 3) here: http://basecamphq.com/tour#overview ...

How to send complete POST to Model in Code Igniter

Hi there, What would be the best way to send a complete post to a model in Code Igniter? Methods I know are as follow: Name form elements as array, eg. <input type="text" name="contact[name]"> <input type="text" name="contact[surname]"> and then use: $this->Model_name->add_contact($this->input->post('contact')); The other would ...

In MVC framworks (such as Ruby on Rails), does usually Model spell as singular and controller and view spell as plural?

I usually see Ruby on Rails books using script/generate model Story name:string link:string which is a singular Story, while when it is controller script/generate controller Stories index then the Story now is Stories, which is plural. Is this a standard on Ruby on Rails? Is it true in other MVC frameworks too, like CakePHP, Symf...

In Ruby on Rails, why will story.votes return an empty Array object, but story.votes.create will actually invoke a method of the Vote class?

In Ruby on Rails, say a Story object can "has_many" Vote objects (a story is voted "hot" by many users). So when we do a s = Story.find(:first) s is a Story object, and say s.votes returns [] and s.votes.class returns Array So clearly, s.votes is an empty Array object. At this time, when s.votes.create is called, it act...

Does Ruby on Rails "has_many" array provide data on a "need to know" basis?

On Ruby on Rails, say, if the Actor model object is Tom Hanks, and the "has_many" fans is 20,000 Fan objects, then actor.fans gives an Array with 20,000 elements. Probably, the elements are not pre-populated with values? Otherwise, getting each Actor object from the DB can be extremely time consuming. So it is on a "need to know" b...

OCL constraints intended prevent node creation in an GMF generated editor only makes it invisible

Hello, I am working on editors created with GMF and struggling with OCL right now. Is there a possibilty to prevent a node to be created if an OCL statement in the mapping evaluates to false? If tried adding an OCL statement to a node and all it does is making the node not visible in the editor, but it is created. There is also an OC...

Where does the data model go in a Prism app?

I'm having trouble where to put our data model in our Prism app. Most, if not all or our data will be coming from web services and the web services are unique for each module. Unfortunately, there will be objects that need to be shared (such as a person/user object). I'm really torn about whether to add these services directly to the ...

Determine if count of related model > 0

I have a model called Stem. I need a 'thumbs up' feature, so I have created a second model called Thumb, which consists of stem_id and user_id. I'm also using the restful authentication plugin for user credentials. I have the 'thumbs up' button working, which adds a row to the thumbs table fine, but I'd like to be able to check if the ...

Why MyModel.all works in Rails ?

Hi, i don't understand this little thing: Suppose, we have "Condition" model class Condition < ActiveRecord::Base end Why Condition.all works ? Condition.all.each { |p| do_something } This syntax tells us, that we have "Condition" class-object instanciated somewhere ? Or is it some convention over configuration case ? I asking ...

Difference between array('Acl' => array('type' => 'requester')) and array('Acl' => 'requester') in CakePHP?

I'm following the ACL tutorial for CakePHP 1.3 and I was wondering if there is a functional difference between declaring a behavior like this: var $actsAs = array('Acl' => 'requester'); and like this: var $actsAs = array('Acl' => array('type' => 'requester')); ...

rails model using class hierarchy from an external gem ?

Hello, I'm working on a project where the data model is : implemented in a separate gem does not use ActiveRecord, nor any relational database storage ( actually it relies on couchdb ) makes usage of namespaces makes intensive usage of class inheritance To simplify the schema, let's say we have the following root class : module ...

Updating Model Schema in Google App Engine?

Google is proposing changing one entry at a time to the default values .... http://code.google.com/appengine/articles/update_schema.html I have a model with a million rows and doing this with a web browser will take me ages. Another option is to run this using task queues but this will cost me a lot of cpu time any easy way to do th...

Cakephp, an elegant solution to quantities?

Hi, I have a shopping cart system in Cakephp, this table has all your usual maguffins: user_ids, product_ids, option_lists ect. It also has quantity. I currently have some awful nested loops to check if the record is the same as any in there, if so add one to the quantity. If not add a new cart item. This loop has to check associated ...

Model relationships in ASP.NET MVC

Hi I recently started evaluating ASP.NET MVC. While it is really easy and quick to create Controllers and Views for Models with only primitive properties (like shown in the starter videos from the official page) I didn't find any good way to work with references to complex types. Let's say, I have these Models: public class Customer { ...

Rails: Multiple "types" of one model through related models?

I have a User model in my app, which I would like to store basic user information, such as email address, first and last name, phone number, etc. I also have many different types of users in my system, including sales agents, clients, guests, etc. I would like to be able to use the same User model as a base for all the others, so that ...

CakePHP: How can I disable auto-increment on Model.id?

CakePHP 1.3.0, mysqli I have a model, Manifest, whose ID should be the unique number from a printed form. However, with Manifest.id set as the primary key, CakePHP is helping me by setting up auto-increment on the field. Is there a way to flag the field via schema.php and/or elsewhere to disable auto-increment? I need just a plain, o...

Django model help

Does anyone have any clue why this doesn't work as expected. If i use the python shell and do team.game_set or team.games It returns an error AttributeError: 'Team' object has no attribute 'game' If i create a Game object and call game.home_team it returns the correct team object Heres my model class Team(models.Model): ...

Overriding as_json has no effect?

I'm trying to override as_json in one of my models, partly to include data from another model, partly to strip out some unnecessary fields. From what I've read this is the preferred approach in Rails 3. To keep it simple, let's say I've got something like: class Country < ActiveRecord::Base def as_json(options={}) super( :o...

Multi-thread conversation in django (like Reddit)

Hay, i have an app which essentially a conversation system (much like reddits) Where a post can have multiple replies, and a reply and have multiplies, and a reply to a reply can have multiple replies (etc) I've made the model like this class Discussion(models.Model): message = models.TextField() replies = models.ManyToManyFi...

CakePhp: model recursive associations and find

Hello to everybody! I've some trouble with a find() on a model on CakePhp. I have three model relationed in this way: Project(some_fields, item_id) ------belongsTo-----> Item(some_fields, item_id) ------belongsTo-----> User(some_fields campi, nickname) I need to do a find() and retrieve all fields from project, a field from Item and ...