I've been struggling to understand why I can easily use seeds.rb to create new Users and their default associations, but when running individual a unit test causes errors. I've tried to get around calling 'Role' as it causes errors in the unit test. I am relatively new to unit testing, but have been using Rails for several years alread...
Can we have a model class which is singleton in Doctrine?
For Singleton classes I should have a private/protected constructor....but this is not possible as I am extending a Doctrine class which has a public constructor
You can argue about the use of the Singleton pattern when interacting with the DB, but just consider this scenario:
...
I'm working on a real estate application, where one Home can be listed by either one or two Realtors. As such, I'm trying to follow the example given in section 3.7.6.7 of the Cake Cookbook. Here's what's going on in my Realtors model:
class Realtor extends AppModel {
var $primaryKey = $num;
var $name = 'Realtor';
var $hasM...
I've gone over the tutorial, used the scaffold command to make a model, etc.
I noticed that it mentioned more experienced programmers would probably create all their models from scratch... What is the "appropriate" way to do so?
If it's a simple answer and I'm just Googlin' the wrong keywords, I apologize in advance.
...
I just migrated my server's photos to an S3. Everything seems to work swimmingly except one little catch.
If a user chooses a photo from his existing media, the server returns a 500 error. I assume this is because it might still be either looking for it on my local, OR it doesn't draw from the photo model appropriately :
a. From my loc...
Is there any C# .NET resource from where I can learn about how to write Model Based Tests ?
using NModel or preferrably Spec Explorer ? just some basic tutorials on how to write MBT ?
thanks
...
I'm trying to execute some logic before deleting a field. I have some models that are dependent on the model being deleted, and I want to make sure that image files related to those dependent models are also deleted, but I'm a bit confused on how the model callbacks work.
I know that I define the before Delete function in the model cla...
I have a Django model:
class Customer(models.Model):
first_name=models.CharField(max_length=20,null=True, blank=True)
last_name=models.CharField(max_length=25,null=True, blank=True)
address=models.CharField(max_length=60,null=True, blank=True)
address2=models.CharField(max_length=60,null=True, blank=True)
city=models.CharField...
I'm trying to access a model for global system settings. It should be loaded in almost every controller. The problem is I can't find any help on getting rails to load the dam thing.
If this helps, the model is called Config and has two columns; 'key' and 'value'
I come from a background in PHP. I remember codeigniter could load models ...
I have models of my tables and would like to do a join using a model as opposed to to a table.
For example, instead of:
$select = $this->select()
->from(array('p' => 'products'),
array('product_id', 'product_name'))
->join(array('l' => 'line_items'),
'p.product_id = l.product_id',
->limit(20, 10);
where I specify the table na...
I had issued with using a ModelStateWrapper in MVC 1 as described here:
http://www.asp.net/mvc/tutorials/validating-with-a-service-layer--cs
As much as I was able to test my application it still felt like there was a dependency/circular reference with the ModelState, the controller and the service layer. With the new DataAnnotation in M...
There is a form: "dropdownlist", "available items listbox" and "selected items listbox", button: Add.
"dropdownlist" is filled with values. OnDropdownChange "available items listbox" is populated with the values taken from db (ajax request). User, using Add button, moves elements from "available items listbox" to "selected items listbox...
class Project(models.Model):
slug = models.SlugField(max_length=100)
main_file = models.FilePathField(path="/home/mn/myfiles/%s" % slug)
This code doesn't work, just illustrating what I'd like to do.
I want to fill in FilePathField when object is accessed (ie. when it is updated in django admin, not when it's created).
Is the...
I'm kind of new to Django and am having some trouble pulling from existing tables. I'm trying to pull data from columns on multiple joined tables. I did find a solution, but it feels a bit like cheating and am wondering if my method below is considered proper or not.
class Sig(models.Model):
sig_id = models.IntegerField(primar...
Currently I have about 40 models and whenever I have needed to do an insert its always just been on a single model, so I have been happy to just use my class model which extends Zend_Db_Table_Abstract
class Model extends Zend_Db_Table_Abstract
However, now one of my requirements is to read a CSV file and normalize it into my database....
I'm building a webapp using the Zend Framework, and I need to model logic or keep track of some logic that has to do with tracking progress towards a goal.
Let me illustrate with a sample goal.
USER Needs to Complete All Three of the following:
A) Activity One
B) Activity Two
C) Activity Three
USER Needs to Complete One ...
So I'd like to set/get a session variable from inside a plugin model that I've included to my project. I tried making a method (one getter one setter) inside the application_controller.rb but this did not work. Where can I make getter/setter methods so that a plugin model has access to them?
...
What happens when two models are associated with a belongsTo and a hasOne relationship at the same time?
Does the framework detect this situation to avoid retrieving too much data?
EDIT: CakePHP specifically, although what other frameworks do would be helpful, too.
...
Hi
I am designing an SQL Report Server Model, to replace a table that was used as a cut down version of the main database to report from. So the report will use the model to report from not the cut down database.
I was wondering if there was quick and easy way to take the Stored procedures, that were used for 100+ report on the cut do...
I have proxy model for user:
class MyUser(User):
class Meta:
proxy = True
How can i get it in templates without pass from view? can i get it only from request.user instance?
I am using template context processor for this:
def m_processor(request):
from main.models import MyUser
mu = MyUser.objects.get(id = reques...