models

:foreign_key not requesting from the right column?

I have three models: for the purpose of asking the question, I'll call them posts, containertable1 and containertable2. Basically, the posts table has a column called misc_id, which has the id of an item that is in either containertable1 or containertable2. I tried to set up a foreign key association, but it doesn't seem to fetch from...

How to get a model to specify a pre-requisite condition?

In my model "Post.rb", I'm trying to have it only return posts if column deleted is 0. In other words, when the user deletes posts, it doesn't remove the item from the database, but rather turns deleted to 1. So if I run Post.find(:all), I want it to automatically add the condition "deleted = '0'". How do I go about doing this from my...

Overriding default_scope in Rails

In my Post.rb model, I have default_scope :conditions => {:deleted => 'false'} But if I try to run Post.find(:all, :conditions => "deleted='false'"), it won't return anything. It's as if the default_scope takes precedence over everything. I want it so that when I do Post.find() it doesn't return deleted posts, but I'd also like to b...

validates_confirmation_of in Rails preventing me from saving a new object.

In my User.rb model, I have this line: validates_confirmation_of :password, :message => "Your passwords should match." Then when the user signs up, the passwords match, everything is great... until I want to add more information to the user object, then save again. But running @user.save returns the error that my passwords don't match...

Help with my codeigniter application!

ok, decided to use the tutorial from ibm.com for the addressbook to learn codeigniter, scrapped the first project, but after I submit the form, I get the following error:Fatal error: Class 'Mcontacts' not found in C:\xampp\htdocs\AddressBook\system\libraries\Loader.php on line 184 what am I doing wrong? please help! I really want to lear...

Granularization of models?

I'm developing a CMS largely based on Zend Framework components. Some of the database tables for this CMS are as followed: site | id | name | ------------- locale | languageCode | regionCode | ----------------------------- site_locale // link sites with locales | siteId | languageCode | regionCode | isActive | isDefault | ------------...

Reverse ForeignKey lookup

I'm new to Django and am still trying to break old PHP habits. Below are two models. To make things confusing they live in separate files, in different apps... #article.models from someapp.author.models import Author class Article(model.Model): ... author = models.ForeignKey(Author) # author.models class Author(model.Model): ...

Help creating model for Django app

Hello, I'm trying to make a childcare administration app with Django but I've some problems with the payments code. Each kid has to pay monthly 10 times a year. These payments have some particularities: Some kids could pay a different amount of money depending on the economical situation of the parents. The amount of the payments coul...

C# - Entity Framework - Understanding some basics

Model #1 - This model sits in a database on our Dev Server. Model #2 - This model sits in a database on our Prod Server and is updated each day by automatic feeds. I have written what should be some simple code to sync my feed (Model #2) into my working DB (Model #1). Please note this is prototype code and the models may not be as...

Codeigniter: Models questions!

Hi... i just got this doubt about models... This is my first 100% MVC project (kind of)... my doubt is...when ill do a join, union or whatever function with more than one table... how i do this? use the same model file of the "main table" or i need to create a new model file using the two or whatever tables?? Tkz... Roberto! ...

Zend Framework Models not loading by autoloader

I've setup my application with Zend_Application. I have an _initAutoload() method in my Bootstrap.php wich looks like this: public function _initAutoload(){ $this->bootstrap("frontController"); $front = $this->frontController; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('Cli...

Associate User with Account in Rails

Hello, I'm very new to Rails (this is my first project). I have a situation where an account can have many users and projects, and users can have many projects and vice versa. I have authlogic running on my Users model. I'm confused about where to go after this. After creating a new user, how do I pass the user information into account?...

Difference between Model and Model Resouce

Hey guys, Im starting a project with Magento. Let me first say, that i come from the MS world, i have never used PHP before, and while im catching up quite rapidly i'm def a php newb. I can't quite seem to grasp the differences between the model, resource model, resource and entity objects and how they are related in the magento archit...

Rails has_one :through association

Rails has a has_one :through association that helps set up a one-to-one association with a third model by going through a second model. What is the real use of that besides making a shortcut association, that would otherwise be an extra step away. Taking this example from the Rails guide: class Supplier < ActiveRecord::Base has_one :...

What is the correct practice to incorporate models?

I am trying to simplify the process of inserting data into my database, so I have constructed a model that handles the variable extraction and data inserting. I understand that this model embodies a function, and then you call this function (such as /controller/model) and pass the relevant data through the model for processing. However,...

ASP.NET MVC - Submit Form with complex Model with EntitySet

Hello There, I'm struggling myself trying to make my form work with my models... So, I have 3 Models Account has_one -> Company has_many -> Individuals -> has_one Document So the account can have one company and many individuals with one document each. When submit my forms I have the following action [AcceptVerbs(HttpVerbs.Pos...

Binding a model without controller/http.context

I have a model called "Channel" which has a bunch of string properties. I fetch data from my data source which returns a hash table. The Keys of this table match the property names of my model. How can I auto-bind the hash table to the Channel model? The binders from ASP.NET MVC seem to do this but you need to use it in a controller w...

Rails checkout form with multiple models

I'm creating a shopping cart based on the one in Agile Web Development With Rails (version 3). I have it set up where "items" are added to a "cart", then upon starting the checkout process, they are added to an "order" object as "line_items". "line_items" represent one "item" in any quantity. Up to this point, I'm not deviating from the ...

Why does Code Igniter give me a white page?

Hey, not sure why CodeIgniter is giving me a blank page when I load a simple model. I'm breaking the code down, backwards, and I can't figure out what's breaking. Here's the controller: class Leads extends Controller { function Leads() { parent::Controller(); $this->load->scaffolding('leads'); } function index() { $data ...

How can I get a total count of a model's related objects and the model's children's related objects?

In Django, I've got a Checkout model, which is a ticket for somebody checking out equipment. I've also got an OrganizationalUnit model that the Checkout model relates to (via ForeignKey), as the person on the checkout belongs to an OrganizationalUnit on our campus. The OrganizationalUnit has a self relation, so several OUs can be the ch...