I have an object called human and that object has a field called job. I want users to be able to add their own jobs (which will obviously be added in their own language) but I want to have any job that is a default in the database to be translated when someone does a Human.job, can rails translate the default if it is in the view but not...
I'm setting up an after_save callback in my model observer to send a notification only if the model's published attribute was changed from false to true. Since methods such as changed? are only useful before the model is saved, the way I'm currently (and unsuccessfully) trying to do so is as follows:
def before_save(blog)
@og_publishe...
I have written in my code like this...
$this->User->saveAll($this->data, array('validate'=>'first'));
$this->User->saveAll($this->data, array('validate'=>false));
'validate'=>false will not check for validations in model. But if I replace false with first, then what will it do?
Thanks.
...
I've got a nested form, structured: Question has_many Answers. So, the questions are multiple choice.
Current form view:
- semantic_form_for @question do |f|
= f.error_messages
- f.inputs do
= f.input :question
= f.semantic_fields_for :answers do |builder|
= builder.input :content, :label => "Answer", :input_html => {...
In any diagram be a uml or any software engineering model diagram whats the difference in using a rounded rectangle and a rectangle.?
----Thanks in advance
...
(CakePHP Version 1.3.4)
I have the following association between a Contact model with Account and Test models:
class Contact extends AppModel {
var $name = 'Contact';
var $actsAs = array('Containable');
var $hasMany = array(
'Test' => array(
'className' => 'Test',
'foreignKey' => 'contact_i...
I'm using the rails3-jquery-autocomplete gem found here: http://github.com/crowdint/rails3-jquery-autocomplete
The instructions are clear for how to query a single attribute of a model and I am able to make that work without a problem.
My Person model has two attributes that I would like to combine and query, however. They are first_n...
Hello, I've faced with following issue, basically I do it like this:
class Account(models.Model):
TraffPerMonth = models.IntegerField(default=0)
Tariff = models.ForeignKey('Tariff')
class Tariff(models.Model):
InetTraff = models.IntegerField(default='0')
and here is the select:
for user in Account.objects.all():
t_traf...
Hi, i'm trying to get model objects instance in another one. And i raise this error :
Manager isn't accessible via topic instance
Here's my model :
class forum(models.Model):
# Some attributs
class topic(models.Model):
# Some attributs
class post(models.Model):
# Some attributs
def delete(self):
forum = se...
I have an app which includes a model "QuesTags". Now when I create an entry for this model in admin.py, the admin displays this model as "Ques tagss", which IMHO is totally unpalatable. Is there a way around( ex. short_description ) to display a custom string instead of parsing the original model name?
...
Hi all!
I have this rather simple Ruby on Rails application : two models Lists and Items. Lists have many Items and Items belong to Lists. OK.
The show method of ListsController prints a page with the list of the items belonging to the given list (in a partial lists/_listOfItems.html.erb). At the end of the show.html.erb view, there is...
I'm working in a CakePHP Model class, writing a function that is supposed to perform a whole bunch of manipulations on the model. I'm trying to follow the skinny controller, fat model idea. However, I don't seem to be able to call any of the model's functions from with in my model. Something hasn't been initialized yet, because I get ...
hello everybody!
i think this is a pretty easy question for you.
I want to clear an attribute of a django-model.
If i have something like this:
class Book(models.Model):
name = models.TextField()
pages = models.IntegerField()
img = models.ImageField()
In an abstract function i want to clear an attribute, but a...
Hi guys,
my problem is that we try to use a MVC (php) framework. After discussing a lot think that MVC is very good, but I´m missing the possibility to write reusable model-(application)logic. So, I´m not sure if we have the right approach to implement our software in a MVC framework.
First I´ll describe the non-MVC, oo-approach which ...
I have a aspx page. Users can perform an action on that page. but that actions goes through series of other actions. for example- suppose there is JOin Community link on that page. When user clicks He is asked to Login/Register(A) THEN He is asked to fill up a brief profile(B) THEN he is asked to join community as member/admin etc (C). S...
Maybe my question is little childish. A django model is typically defined like this:
class DummyModel(models.Model):
field1 = models.CharField()
field2 = models.CharField()
As per my understanding, field1 and field2 are defined on the class level instead of instance level. So different instances will share the same field value...
Hi,
I have 2 models, User and Evolution. User has many Evolution, Evolution belongs to User.
I have 10 000 users and I want to do a condition that give me 500 users that DON'T have today's date in the Evolution table.
Originally, I was taking every one in the USER table and then I was looking if they had their row in Evolution like:
...
I have an Activities model that acts as sort of a dashboard for the entire rails app I have. I have some :after_create callbacks passing the Customer object and a generic message into the Activity model to store the information. This works fine and dandy by outputting "has created customer Microsoft in the Toolbox." but I can't seem to f...
In my application i have a threaded commenting system which i call status messages. i have a few models as follows
users(id, name......)
status_messages(id, message,......, user_id)
status_replies(id, message,......, status_message_id, user_id)
is this the right way of writing a commenting system ?
A user can set status messages and...
I have a class method that I would like to return a error from, is something like this possible?
class Foo < ActiveRecord::Base
def self.do_this
if b = Bar.find_by_id(5)
return 'Yea'
else
self.errors.add_to_base('I was not found')
end
end
end
...