Displaying 20 results from an estimated 8000 matches similar to: "Active Record and consistency"
2006 Nov 04
0
ActiveRecord
I''m running into a bit of a ideological and functional problem with
ActiveRecord and would like to find out if some of these concerns are
valid. Hopefully someone here already knows the answer...
The concerns are that ActiveRecord has a lot of activity involving data
validation (validates_uniqueness_of, validates_associated) and model
definition (belongs_to, has_many, has_one).
2008 Apr 07
2
Simple active record issue. I must be missing something.
Here''s a seemingly simple ActiveRecord use case. I have Projects and
Users. Each project has a single team leader as well as a review team
that consists of several users. I would like to use the same User
model for authentication and just reference these users in my Project
model.
I tried this but got an "unknown column" error (for User.project_id)
class Project
has_one
2006 Jul 30
3
ActiveRecord - Multiple Address for a single record
I''m trying to figure out the Rails way to model the following problem:
I have 2 tables. One (let''s call it location) contains a single
address. The other (let''s call it company) contains 3 address. I''m
trying to figure out the best way to model this. I''ve created an
address table, a set up the model as follows:
class Address <
2006 Jan 22
5
has_one not working as expected?
I messed around with Rails for a while last year, but then got busy and
had to drop it. However, I now have time again, so I''m starting to play
around with a simple database schema to model my extensive collection of
photographic material, including equipment, negatives, photographs,
etc. I''m running into an issue with using belongs_to/has_one methods.
Read on for an
2006 Apr 08
2
one-to-one relationship confusion
Hello,
I posted a similar email, earlier in the week, but I still must not be
getting it.
I have a customer that aggregates two addresses; a shipping address
and a billing address. Addresses can also be referenced by other
objects in a similar way, so I would really like to avoid putting the
keys referencing the customer or other objects in the addresses table.
Addresses are exclusively
2005 Dec 29
0
Problem destroying some record with relations has_many has_one
Hi guys!
I''m developoning a small web-app, everything goes quickly and well!!
I need some help, im trying to destroy at the same time some records of
varius of my models. My model are relathionate with has_many, has_one.
What could be the best way to do it? Could i use act_as_a_tree or there
are other cool way?
Thanks
P.D: Sorry by my bad english
2005 Dec 29
7
belongs_to causing NoMethodError exceptions ... ?
I''ve got a really strange problem using belongs_to. I apologize in
advance for the length... this is going to take a while to explain.
Basic idea: Creating a User requires that the user enter an email
address and activation key that matches an existing PendingUser.
After creating the user successfully, that pending user should be
marked as "used".
The problem:
When I
2005 Dec 15
8
How to ensure deletes cascade to associated models?
I have the following models:
class Resume
belongs_to :resume_assignments
end
class User
belongs_to :resume_assignments
end
class ResumeAssignment
has_one :resume
has_one :user
end
When I delete a resume, I want to make sure that its associated
ResumeAssignment gets deleted also. Calling destroy_all to delete
some resumes doesn''t seem to do this. Is there an option that will
2003 Nov 02
2
dies on start-up: Auth process
I was digging through some of the archives and ran into someone who was
having the same problem, but for completely different reasons....i think.
dovecot: Nov 02 07:58:51 Info: Dovecot starting up
dovecot: Nov 02 07:58:52 Error: Auth process died too early - shutting down
dovecot: Nov 02 07:58:52 Error: child 27673 (login) killed with signal 11
dovecot: Nov 02 07:58:52 Error: child 27672 (login)
2006 Apr 08
4
Stack level too deep error :(
Hi,
If anyone has some time to help with my problem that would be really good :)
I am getting a "stack level too deep" error when saving an object to the
database when it is has a has_one relationship to another object I wish
to save and associate after it.
If goes a little like this
class Quote < ActiveRecord::Base
belongs_to :eventdetail
has_many :bookings
# An
2006 Aug 18
1
How update a record which hasn''t id column?
Hi, I''ve two database tables 1-N related and one of them doesn''t have id
column:
matches (id, more columns), match_details(match_id, ... more columns)
Also have two models that represents these tables:
Match MatchDetail
has_one :match_detail belongs_to :match,
:foreign_key => ''match_id''
When I
2006 May 14
2
one to one, but only with one table per record
Hi,
I have a ''descriptions'' table which has_one of lots of other tables.
The other tables all belong to a description. But I only want each
description to have one record from any of the tables. So a
description can''t have a room and photo. There has to be one
description for each room, and one description for each photo. Any
idea if there''s a reasonably easy
2008 Jan 02
6
problem when editing record in polymorphic relation
I have the following three models created applying the polymorphic
concept
==========================================================================
class SoftwareCi < ActiveRecord::Base
has_one :ci, :as => :content
end
class HardwareCi < ActiveRecord::Base
has_one :ci, :as => :content
end
class Ci < ActiveRecord::Base
belongs_to :content, :polymorphic => true
end
The
2007 Jan 30
2
save does not cascade in 1.2.1?
Hi All,
I have the following test case which worked just fine before I upgraded
to rails 1.2.1:
def test_update_settings
assert @unit.setting!=nil # loaded via fixtures
assert_equal @unit.setting,@current_setting # also loaded via
fixtures
@unit.setting.mode = true
assert @unit.save
@unit.reload
assert @unit.setting.mode
end
where @unit is declared with
2006 Apr 22
0
Is it possible to have one class containing tw
Hello fellow Rail-builders,
Is it possible to declare one class that includes two polymorphic
fields as such:
class Mark < ActiveRecord::Base
# attribute: value, :string
belongs_to :markable, polymorphic => true
end
class Property < ActiveRecord::Base
has_one :name, :as => :markable
has_one :value, :as => :markable
end
?
Based on what I know of the underlying
2008 Sep 16
3
has_one :through eager-loading problem
I have a problem with the :include option in find for my
has_one :through association.
I have Users, Profiles and Customers, all connected to each other with
a has_one :through => :membership association like this:
class Profile < ActiveRecord::Base #could also be user or customer
has_one :membership # i saw an acrticle of Ryan about
has_one :through, there this would be has_many, is
2008 Feb 19
0
Issue with Observers and has_one association...
Hey Guys,
I''m getting a peculiar bug working with Observers and has_one
associations. When a has_one association is invoked by an Observer it
always returns null. I looked in the development.log file and the SQL
for the has_one association isn''t even being executed. On the other
hand, when I replace the has_one association with just a hand crafted
method, it does get called
2007 May 14
0
building and saving has_many and has_one relations
Hi,
I am very confused about an aspect of has_one and has_many relations,
with regard to using the build method, and saving the belongs_to side.
It''s a somewhat long post. so please bear with me :)
First let''s consider the has_one scenario. Let''s say I have a student
who must own exactly one car:
class Student
has_one(:car)
end
class Car
belongs_to(:student)
2006 May 12
1
can I fake has_one :through?
I''m having a difficult time wrapping my head around a set of models
and their associations and seeing how they map into Rails. I''ll try
to lay out my problem using the has_many and belongs_to structures. I
have a RuleSpace, a Rule, and a Subject.
A RuleSpace has_many Rules
A RulesSpace has_many Subjects through Rules
A Rule belongs_to (many) RuleSpaces
A Rule has_many
2008 Sep 29
1
has_one :through with :source. How to alias association?
Hi to everyone,
I have the following models:
class Attachment < ActiveRecord::Base
has_attachment :content_type => [:image, ''application/pdf''],
:max_size => 3.megabytes,
:path_prefix => ''../private/attachments'',
:storage => :file_system,
:processor => :rmagick,