I'm trying to sort out how to add a context sensitive function (e.g. def get_user_full_name()) that will get triggered from the default and onupdate specifications on a column. I'm trying to set a composite field that combines the first and last names into a single full name value to avoid having to constantly concat the two fields in a...
I have a domain-specific application that is used by a few customers. The customers each have their own specific requirements. Sometimes
extra fields, sometimes different rules and funcitonality.
The domain objects change very little but the customer.
Because the domain objects are fairly static I opted for anemic domain model with fi...
Hi,
I have a custom query which eventually returns a list of objects. I need the function to return the actual objects but I don't want to hit the database twice for every query since it's already an expensive query. How can i return a model instance without hitting the db?
NB: I presume doing something like the following will actually...
Is there a Java framework that allows me to extend the data model at runtime with new fields and maybe even classes?
Ideally, non-Java people should be able to do that (i.e. with a config dialog).
...
I want to create a model, "Whitelist" to build a list of users that I do not want displayed in my main model, "User".
Example Controller
def index
@users = User.find(:all) #These are to be filtered behind the scenes in the model
end
Example Model
class User ActiveRecord::Base
has_many :whitelist
def self.find
#Add somethi...
I'm new to programming, iphone application programming in specific. After reading a bunch about MVC I decided to give it a try in a small application. As to my understanding, MVC works like this:
Model: data, manipulating data, retrieving data.
ViewController: formats data from the model (NSDate to specific style), etc.
View: the actu...
Hi,
for a doctrine model I'm making I don't always need to fetch all the columns I was hoping that I could solve this using
$query = Doctrine_Query::create()
->select('a');
if(!empty($value)){
$query->select('b');
}
$query->execute();
but this does not work...
Does anyone have a clue how this could be done?
...
I'm getting a very odd error when I attempt to access the find method of a has_many relationship.
What am I doing wrong syntactically?
# Instructor model
class Instructor < ActiveRecord::Base
has_many :events
end
# Event model
class Event < ActiveRecord::Base
belongs_to :instructor
end
# Controller snip-it
i = Instructor.first
co...
Hi,
When using Model class like this:
class MyModel(models.Model):
def __init__(self, *args, **kwargs):
self.myfield = models.Field()
super(MyModel, self).__init__(*args, **kwargs)
It doesn't take into consideration myfield(in the admin form, when saving the object... )
But if i declare like that:
class MyModel(m...
Say I have a very simple model that looks like this:
class Model_Person extends ORM
{
/*
CREATE TABLE `persons` (
`id` INT PRIMARY KEY AUTO_INCREMENT,
`firstname` VARCHAR(45) NOT NULL,
`lastname` VARCHAR(45) NOT NULL,
`date_of_birth` DATE NOT NULL,
);
*/
}
Is there a way I can I add sort of a pretend property with...
I'm no expert in UML, I just took a course before I graduated that spent a significant amount of time on UML modeling. I understand the basics but I was working on a project the other day and just for my own curiosity, I was wondering how you would model a callback. Here is a portion of the code I was working on
class OnChangeHandler...
tags_controller.rb:
def index
@title = "tags"
@posts = Post.tag_counts.collect do |tag|
Post.tagged_with(tag).first(:order => "updated_at DESC")
end
@posts.uniq!
end
tags/index.html.rb:
<%= render 'latest' %>
_latest.html.erb:
<%- for post in @posts -%>
<%- post.tags.each do |t| -%>
<%= link_to t.name, tag_path(t...
I have the following data structure for storing meridians and parallels.
Each cartographic point stores:
A] geographic and spatial coordinates, cartographic distortions, etc.
B] pointer to north/south/east/west node.
It allows to store relationships between points, first of all their affiliation to the
meridian/parallel...
class...
Hi,
If I have two models. Model1 belongs_to Model2, and Model2 has_one Model1. Thus I can access Model2 from Model1 as well as Model1 from Model2. Now my question is, can I change the relationship to Model2 belongs_to Model1 and Model1 has_one Model2? It also can let me traverse from Model1 to Model2 and from Model2 to Model1. I'm not s...
Hello guys,
I would like to get an insight into your daily work :P
How do you read the Person data into the PersonViewModel ?
Is it just a
PersonViewModel pVM = staticHelper.ConvertPersonToPersonViewModel(person);
or is there something cooler?
...
Guys,
I've got a controller called "ResourcesController", but its really managing the CRUD for two different models.
I don't actually have a model called Resource, so the controller is balking that it can't find it.
Is there a way I can inform the controller which model I'll be working with so it doesn't freak out?
The error that is ...
I'm trying to define conditions on relationships with Doctrine. Is it possible?
I mean something like this:
class User extends Doctrine_Record
{
public function setUp()
{
$this->hasMany('Article as ReallySpecialArticles', array(
'local' => 'id',
'foreign' => 'user_id',
'conditions' =...
hi,
un rails i can simply insert the params into the database with one command, when all form-field names are the same like the model-field names. is this possible in django as well, or do i have to set each param individually. i have like 20 fields, so it's a bit of a mess.. :)
something like:
blah = Contact()
blah.content = params[]...
I have MS SQL in my local development server and production server. The DateTime format of my local server is "mm/dd/yyyy" but the format in production server is "dd/mm/yyyy". Every thing worked fine in my local server , but when I try to enter a date like "05/31/2010" in my production server, the Model Validation threw an error "The va...
Is there a way to get the current variable?
lets say that i have a "title" attribute in a method and i want to check in with the old value of the variable ?
how could i accomplish this ?
...