similar to: STI and foreign_key problem

Displaying 20 results from an estimated 10000 matches similar to: "STI and foreign_key problem"

2006 Apr 03
2
Problems with STI in has_many/belongs_to in Rails 1.1
I have a problem that surfaced in my attempt to upgrade my application to Rails 1.1. We have a STI model on the "belongs_to" side of a has_many/belongs_to relationship. All my unit tests for this model pass, and the relationships all seem to work fine. But in my functional tests, I''m getting errors. I''ve traced it back into the call to the has_many
2006 Jul 13
5
Relationships: one model referencing same table for different data sets?
Hi, After I''ve saved, I want to display the Description from the Codes table that corresponds with the ID in the Cause table. Rails doesn''t seem to like that, because on my form, I have two sets of data in combo boxes that come from the Codes table. So, in the show template, I can''t do this: Cause of Death: <%= @cause.code.description %> Any ideas? The
2006 Jul 10
9
ROR questions
Hi, ? I''m a Ruby on Rails newbie.? I''ve been tasked with building our office''s first ROR application, and I am the only one working on it, so I am muddling through with a couple of books...? Moving along slowly but need some discussion time with some people who KNOW it and can maybe offer some answers to questions I haven''t found in my books. ? First - what is
2006 Jul 25
2
Authentication design/ideas
Hi all, I''m using acts_as_authenticated for the front end facing part of my site. I have a model called Customer. I now want to protect the admin sides of things. I am thinking of using Ezra''s acl plugin (http://opensvn.csie.org/ezra/rails/plugins/dev/acl_system2/README) for this. My only problem is that I don''t want the model for admin users to be called Customer,
2006 Aug 04
2
problem eager loading with sti
Here''s the setup (working off Rails 1.1.4): Class Project belongs_to :employee Class Employee < Person has_many :projects When I try to paginate(:employees, :include => :projects) I get the error "Association named ''projects'' was not found; perhaps you misspelled it?" I can :include other models that the Person class has_many or habtm of, and if I
2010 Aug 10
4
(Dreaded) STI, belongs_to
Having problems with STI. Names below have been changed to protect the innocent. Imagine a system that allows someone to apply for one of two different types of school scholarships. Each scholarship goes through a different review process, represented by a state machine (this is not a state machine question). So there are two state machine classes that differ slightly and subclass a generic
2006 Jun 27
3
belongs_to <parent name>, :foreign_key modifier not working
All, I have two ActiveRecord objects. TargetList has_many Targets Targets belongs_to TargetList I''ve specified belongs_to :target_list, :foreign_key => ''DataSetID'' Queries generated by various methods in target_list do not seem to see the foreign_key name and keep trying to query my Target table using "target_list_id" (the default foreign
2006 Aug 07
1
datetime_select problems
Hi, I have a datetime select in my form like this: DATE/TIME REPORTED: <%= datetime_select ''report'', ''rep_date'' %> This works beautifully for creating a new record. The data is saved as: 2006-08-07 11:33:00 Now, the problem is when I try to load the form with saved values to do an update. The above code works and loads the saved data in another one
2005 Dec 22
3
foreign_key setting ignored
I''m having a spot of bother creating a ''has_many'' relationship between two legacy database tables. The relationship is ''company'' table has many linked records in the ''contact'' table. Iv''e used ''generate scaffold'' on these tables and everything is fine. I then decided to define the relationship in the
2006 Feb 09
2
Crazy @55 Inheritance
I have one table, called "people". Within this table, there are type "users", "managers".... etc. So, basic STI. Now, I want a "user" to have one manager, but a "manager" to have many "users". Since I don''t want to use HABTM... how do I set this relationship up seeing that :has_one, :belongs_to and :has_many don''t
2006 Feb 10
3
[Req] polymorphic associations howto
Hi people, I''m looking into polymorphic associations as a way to cleanup some messy parts of my code. I think they will allow me to do exectly what I need, but since there''s little to none written on this subject, I''d be delighted if someone could shed some light on this. Especially what the different options and needed table structures need to be. Thanks, -
2007 Sep 13
7
Namespacing Models
Hello everyone, Do you feel it? The little shiver down your spine when you think of "namespacing" in rails? To some thats a common feeling, to people like myself who enforce absolute organization have already thought about the need for namespaces in rails. Now I do understand this is an ongoing effort... to some degree. Controllers and routes, from my experiences work well, that being,
2006 Mar 19
1
some strange behavior for has_many with STI
Hi all, I''m having some trouble with a has_many association on a table using the single table inheritance model that I''m hoping someone can help me with. The schema for the table is: CREATE TABLE `comments` ( `id` int(11) NOT NULL auto_increment, `user_id` int(11) default NULL, `type` varchar(20) NOT NULL default '''', `type_id` int(11) NOT NULL default
2006 May 15
3
Building a library system (ActiveRecord question)
I''m rebuilding a library/academic system (including public web) using excellent Rails. I''m trying to make the most out of ActiveRecord, but rethinking the database schema spawned some potential issues that may cause problems down the road, so I want thoughts on this from more experienced community. The thing is, all entities in the system have a fixed set of metadata. At
2005 Dec 27
3
Trouble combining :has_many, :finder_sql and :conditions to create a sub-search
I''m sure there''s something right under my nose that I''m missing. I have two tables with two parallel one-to-many relationships. I wish to use the :finder_sql parameter to essentially ''or'' the two foreign keys. What isn''t working for me is performing a ''sub-search''. Let''s say the tables are "stores" and
2006 May 14
2
object class with STI and Polymorphic Assoc''s.
Hi, lets say I have a a table, "Linkings" that I am using for polymorphic associations. One of the associations is to the "person" table, and there are several other associations. "Person" has 2 types, "slacker" and "suckup". It is modelled as such: class Linking < ActiveRecord::Base belongs_to :person belongs_to :linkable, :polymorphic
2011 Jan 15
3
has_many :through with Single Table inheritance
I have the following model structure setup. class User < ActiveRecord::Base end class Parent < User has_many :relationships has_many :children, :class_name => "Student", :through => :relationships, :conditions => "related_as = ''parent''" end class Student < User has_many :relationships
2008 Jan 27
4
(REST) Nested routes
Hello, I''m in troubles with nested routes. I have three models: Team, Tournament and TeamTournaments class Team < ActiveRecord::Base has_many :tournaments, :through => :team_tournaments has_many :team_tournaments class TeamTournament < ActiveRecord::Base belongs_to :team, :foreign_key => ''team_id'' belongs_to :tournament, :class_name =>
2006 Nov 21
5
acts_as_ferret with STI models
Can acts_as_ferret search only one of the inherit models in the hierarchy of STI models? Say you have Contents, with types articles and comments. I know that you do Contents.find_by_contents, but can you also create indexed for Comment and Articles? Thanks for you help Miguel -- Posted via http://www.ruby-forum.com/.
2006 Mar 15
1
Through method problems with custom foreign_keys
A person has a many company_branches and A company_branch has many people. This join is represented using a "contacts" table. I am using a legacy schema so i am forced into using non-standard rails primary keys. I am using the new through relationship in rails 1.1. p=Person.find(1) b=p.company_branches # gives this error: ActiveRecord::StatementInvalid: OCIError: ORA-00904: