similar to: ActiveRecord

Displaying 20 results from an estimated 6000 matches similar to: "ActiveRecord"

2006 Nov 04
0
Active Record and consistency
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 Jul 22
2
ActiveRecord Associations issue
Hello all and thank you for reading this message. I am new to RoR, and ruby too, but i am quite excited about it. I am developing a RoR project and with active record associations in the following manner # Tables (all tables have only one record) CREATE TABLE `webcars_development`.`cars` ( `id` int(11) NOT NULL auto_increment, `model_id` int(11) NOT NULL default ''0'',
2006 Jun 21
1
ActiveRecord has_one default value
My apologies if this is a dumb question, but I''ve searched around and haven''t been able to come up with a solution. Is there a way when specifying a has_one association to specify a default value for an object if data is missing in the child table. For instance: class Student has_one :university end if no university is associated to the student in the database, I would
2009 Oct 05
0
ActiveRecord Polymorphic Inheritance
I am using RoR ActiveRecord polymorphic inheritance and was wondering if it''s possible to access the base class'' association methods in the invocation of either to_xml or to_json without having to depict the base class data in the serialized string. Here are my classes: # base class class Asset < ActiveRecord::Base belongs_to :resource, :polymorphic => true
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 Apr 11
5
Multiple "has" in ActiveRecord
Please excuse a newbie question, but I couldn''t find anything by searching the archives. What I want to know is how to have multiple references to the same class/table within a class. For example, let''s say I have a table called People: create table people ( id serial8 primary key ,name); which just holds a list of the people in the database. Then I have another
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 Jun 03
8
confused about ActiveRecord relationships
I am very confused about where to put the belongs_to and the has_one (and other relationship identifiers). I have read the RDoc and the agile book many times about this and I think i still see it backwards. Let me outline my app so you have an understanding... I have 2 tables: Schools { id, school_name, address_id } and Addresses { street1, street2, city, state, zip, country } *** this
2006 Jul 01
0
activerecord generating wrong syntax with postgresql
I''m using activerecord outside of rails and find_first generates sql that postgresql doesnt'' like. This is rails 1.1.4, with everything up to date via "gem update". This is the command line: ruby -rrubygems seca -c ../etc/seca.cnf cert --export 1 --format pkcs12 --key root.key >root.pfx This is the error: (PGError: ERROR: argument of WHERE must be type
2006 Jan 06
0
bug rails activerecord association join
hi, I found a bug in ActiveRecord association SQL INNER JOIN codes. in has_many, has_one, habtm and belongs_to queries the foreign key is determined from the table name of reflection and self. but that''s worng because if you use a global prefix or suffix for your tables the foreign keys will be in format of PREFIX_CLASSNAME_SUFFIX_id which is wrong, because it breaks the advantage of
2005 May 14
2
ActiveRecord::Associations::ClassMethods Documentation Issue
I''m curious, but isn''t this example in the documentation for ActiveRecord::Associations::ClassMethods somewhat counter-intuitive? The SQL DDL is correct for the way it''s used in the models. But isn''t it more logical that an author would have many posts, rather than many authors having one post? From
2010 Oct 04
2
newbie q on activerecord - has_one and has_many on same table?
Hi I have a table where I need to identify one of the children as the "prime" child. So, its like: Parent has_many :Child has_one: Child :as :prime_child (?) or something like that? Do I put something like prime_child_id in the Parent table? Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this
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
2006 Mar 18
1
has_many and validates_associated
By trial and error I seem to arrive to the conclusion that 1. Validation recurses through has_many by default and a root save! call raises an excepcion if some child no matter how nested is fails validation 2. Validation does not recurse through has_one by default and you can change this with validates_associated, in which case exceptions behave like above
2006 Jun 28
0
ActiveRecord mapping users to icons
In a simple webapp containing users and user icons, what''s the right way to use ActiveRecord to store these objects and then designate a single ''primary'' icon for each user, given: - a set of users. - for each user, zero or more icons they''ve uploaded (tied to their account). - for each user, zero or one icon from their set of uploaded icons designated as
2013 Feb 25
3
ActiveRecord associations: design question
Hi guys, In my Rails app, I have three models: A, B and C, with the following relationships: - B hasMany C - C belongsTo B I would like A to "has_one" instance of B+C. By that I mean A needs to be linked to a specific instance of B AND a specific instance of C. My first guess would be to create a fourth object, say B_plus_C that would: - belongs to B - belongs to C - belongs to A Is
2006 Feb 02
1
circular table refs in activerecord
I cannot find this anywhere, and it is holding up a project. I have a *very* simple rails app with three tables, one of which is the users table: users: Column | Type | Modifiers ---------------+-----------------------------+----------------- id | integer | not null default nextval(''public.users_id_seq''::text) login
2007 Sep 05
8
Hi..Guys new plugin again
Hi.. Guys new plugin again Foreign Key Associations is a plugin that automatically creates associations based on foreign-keys. The associations are created at runtime-ie. as your ActiveRecord models are loaded-so they will always be up-to-date. For example, given a foreign-key from a customer_id column in an orders table to an id column in a customers table, the plugin creates:
2005 Dec 19
4
has_one, the = operator and validates_associated
Dear readers, I am puzzles by the following, imagine models A and B. A has_one B and B belongs_to A. So far so good. But rails does this great thing by relfecting on this relationship and enables me use the equals sign to do A.B=B. But now comes the puzzlement. Whenever you do this B is supposed to be saved (see,
2006 Aug 19
1
Re: validates_associated
On 8/19/06, Alastair Moore <alastair-mb+lb5rSoAr10XsdtD+oqA@public.gmane.org> wrote: > > Hello all, > > Having a bit of a problem with validates_associated. I assume I''m missing > something out but basically got these two models - > > class Seller < User > > has_one :profile, :foreign_key => ''user_id'', :dependent => :destroy