I am fairly new to Ruby on Rails, and I clearly have an active record association problem, but I can't solve it on my own.
Given the three model classes with their associations:
# application_form.rb
class ApplicationForm < ActiveRecord::Base
has_many :questions, :through => :form_questions
end
# question.rb
class Question < ActiveR...
I've been using Ruby for the first time on a project at my work, so I am still somewhat learning the ropes (and loving every minute of it).
While I understand the point of the map.connect functions in the route.rb file, I don't understand the "resources" and "named route" features of Rails. I have my Rails book here and read it over se...
In django, I'm trying to do something like this:
# if form is valid ...
article = form.save(commit=False)
article.author = req.user
product_name = form.cleaned_data['product_name']
try:
article.product = Component.objects.get(name=product_name)
except:
article.product = Component(name=product_name)
article.save()
# do some more form...
I am creating a simple todo app where I have 2 types of tasks.
1) regular tasks - These have a due date
2) recurring tasks -These are poped up as reminders on specified date. They can be created either as weekly or monthly reminders. If created for a week, it will be poped up on each week (on a specified date on the week). Likewise for...
Hi,
I am having difficulties with listing this type of data. Scenario is
as follows:
user1 add's a friend called user2
user2 confirms that user1 is his friend
what should happen is user2 and user1 see's each others name in their
friends list. What's happening now is I am able to add user2 to user1
friends list but user1 cannot see us...
My application setup with 2 modules admin and default
I test the controller which works fine on modules
but the models doesnt work
I created a model application\modules\admin\models\User.php
<?php
class Admin_Model_User{
}
inside the controller
$user = new Admin_Model_User();
Fatal error: Class 'Admin_Model_User'
not found...
Hi
I'm reading programming best practices and it is said that when creating a function we should make it do a only single specific task.
I got model functions that retrieves data and it's related data. Example:
$this->Student->StudentAssignments();
Currently this function retrieves the student's assignments plus the question for each ...
Hi,
is there a better way to work with ZF useing the mappers, real life objects and table_objects.
This is how I do it with Zend Framework:
class User_DbTable extends Zend_DB_Table_Abstract{
protected $_name = "user"; // name of the table
}
the user class -> user object:
class User{
protected $_id;
protected $_name;
pr...
How can you have model declarations at two different directories in Django?
I have the model at the directory Code which contains "init.py", "models.py" and "admin.py".
It is working properly alone.
I want to have the directory History which has the model of the revisions of the given questions. I have the similar files in the director...
I was following the screencast on rubyonrails.org (creating the blog).
I have following models:
comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
validates_presence_of :body # I added this
end
post.rb
class Post < ActiveRecord::Base
validates_presence_of :body, :title
has_many :comments
end
Relations ...
I've created 3 models:
Article: contains an article
Tag: contains tags
ArticleTag: meant for associating a many-to-one tags to article relationship. It contains a tag_id and an article_id.
The problem I'm having is I'm fairly new to the active record technology and I don't understand the proper way to define everything. Currently, wh...
Hi,
Is there a way to control the data coming from the internet from specific address through the network card before it received by the kernel of the operating system using C++ or any language?
In another word,
Is there a way to access OSI Seven Layer Model using C++ to control the data passing through any layer of the seven layer or ...
Can a model depend on another model? Say I have a log model that other models want to access.
...
The method to walk through apps/models and look into each file for classes is not what I'm looking for
...
I have a model with field defined as
p = models.DecimalField(max_digits=12, decimal_places=6)
But the decimal_places=6 is only for internal accuracy. I only want 2 decimal_places to show up in the admin fields. So I thought perhaps I could do something with properties. But properties don't show up as fields in the Admin interface. E.g...
I'm writing an application in Qt (with C++) and I need to represent an object structure in a tree view. One of the ways to do this is to create a model for this, but I'm still quite confused after reading the Qt documentation about the subject.
The "structure" I have is pretty simple - there's a Project object that holds Task objects in...
My terminology is probably way off here but basically I'm trying to learn the ropes of ASP.NET MVC and so far so good (largely thanks to Phil Haack and Scott Hanselman's tutorials). One thing which I haven't seen addressed yet is the 'right' or most elegant way to pass multiple data models to a view. To help put the question in context, ...
hi, im doing a custom validation but it does not display error message when invalidated.
do you know where is the problem? I think the problem might be in the invalidate function. do you know how to set it up for the nested validation like this one?
var $validate = array(
'receiver' => array(
'maxMsg' => array(
'...
Hi everyone,
I know naming conventions for tables used by plugins generally start with the name of the plugin and then the model pluralized. For example lets say I had a plugin called Poll, with a model also called PollPoll and another model called PollTag then the resulting table names would be poll_polls and poll_tags. They would also ...
Hello.
I want that objects of one model(Thing, list of everyday things, variable length) will be fields of model Day(date, thing1, thing2, ...). It's possible?
If it's not possible, i will use Day(date, fk->Thing), but how in Django admin interface i may list table, where in column - no of exercise repeats and in row - dates and how edi...