similar to: has_many :through with Single Table inheritance

Displaying 20 results from an estimated 10000 matches similar to: "has_many :through with Single Table inheritance"

2013 Jun 22
4
ActiveRecord::Base.transaction - SystemStackError - stack level too deep:
Im having an issue that seems to only happen when trying to use a transaction. Ive used transactions many times in the past and Im at a loss as to why im getting the stack level too deep problem. SystemStackError - stack level too deep: actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:70:in `'' I have a StackOveflow with more detail -
2006 May 28
7
Self-referential has_many :through relationship
Hi, I have a self-referential has_many :through relationship setup to track relationships between users. Basically relationships are modeled as a join table with an extra column ''relation''. create table relationships ( user_id integer unsigned not null, friend_id integer unsigned not null, relation char(1) not null, ) --- relations --- f = friend r = request to
2010 Aug 18
6
Once I added this HABTM, one of my 'through' relationships, on a non-habtm model, seems to have broke?
I''m a rails newb and have been Googling about this, but I''m still stumped. Not showing everything here, but basically it should be a pretty common setup so I''m sure others know what I''m doing wrong. - A meter can belong to many meter_groups - A meter_group can have many meters. - A user can ''subscribe'' to viewing a meter_group (Subscription)
2008 Apr 18
3
has_many and belongs_to with non-primary foreign keys
Hi, I''m having a bit of trouble with my first Rails app. ---- I have two tables: create_table :items do |t| t.column :created_at, :timestamp t.column :user_id, :int t.column :text, :text end create_table :users do |t| t.column :user_id, :int t.column :name, :string end ---- I''m trying to use the "user_id" field to link both tables, with each user
2006 Jan 18
5
Inserting the parent Id to the child table
Hi All, I need your suggestions for the following. I am still learning RoR and pardon my ignorance. I have say two tables. Table A : students Table B : addresses Table B has student_id as the foreign key to Table A If I am displaying the list of students and wanted to get individual students addresses based on their id, is the only option is to get the id from students controller method list
2006 May 23
1
Validating a required relationship.
Hello, I''m not sure if I''m missing something blindingly obvious here. All the relationships that Rails comes with assume 0..n, yes? It''s not a strict 1 to 1 or 1 to n because it''s optional. My question is this - What is the best way to implement a required relationship? For example, if I require that a comment is made by a user (a user has many
2006 Mar 31
18
Modelling Foreign Keys
Can someone point me to a reference or tutorial that shows how to map foreign key relationships in the model? For example given: Users id name email Posts id user_id title How do I associate user_id with users.id in the Post and User models? has_many and belongs_to don''t seem to do it. -- Posted via http://www.ruby-forum.com/.
2006 Apr 09
1
Join using :THROUGH - SQL is wrong even when using :SOURCE
Here''s a join table for an educational institution: create_table "student_appointments", :force => true do |t| t.column "supervisor_id", :integer, :default => 0, :null => false t.column "student_id", :integer, :default => 0, :null => false t.column "course_id", :integer, :default => 0, :null => false [other columns
2008 Mar 29
3
primary key?
can you use 2 pirmary keys. the standard user_id key exists but i would also like to use another key for my links. i am not sure how to implement this. also i don''t want any auto incrementing of this second primary key that i would like to use for my relationships. if there is a good db, model, relationship tutorial out there i would love to know about it.
2008 Jul 15
9
Beginner Question.
I''m just getting into RoR, coming from a long PHP background. So far I LOVE IT! I''m hitting a roadblock with updating my mysql database. For simplicities sake, I have 2 tables and here are the relevant columns. Table Users id name email Table Issues id createdby assignedto reportedby In my models I have everything mapped properly I believe. When I try to update the
2006 Feb 27
4
2 belongs_to to the same parent table
Hello! I have 2 table: users and buddies User: id, name, ... Buddy: id, user_id, user_buddy_id, ... So if you have 2 users 1,jack and 2,fred and fred is a buddy of jack, there is a Buddy object: id=1, user_id=1, user_buddy_id=2 I can declare only one belongs_to in Buddy and one has_many in User. And there is conflict if I had the second one (the first one is discarded) class User has_many
2006 Nov 02
4
Still Having Problems With :through When Going To Same Table... Help... please :-(
I am having a problem with doing a :through that goes back to the same table. The following are my two classes: >>>>> class User < ActiveRecord::Base has_many :spanks has_many :spanked, :through => :spanks, :source => :spanked_user has_many :was_spanked_by, :through => :spanks, :source => :user end class Spank < ActiveRecord::Base belongs_to :spanker,
2006 Apr 06
4
using two foreign keys to the same table
i am working on a task manager with ruby on rails. it is my first major project, so i''m still gettng my feet wet as i learn. i''ve been trying to use the built in relationships to link my tables together, but i''m not able to use the same naming conventions. for each task, it has a field for the creator, and another field for the assignee. both of these fields
2006 Jan 04
4
HOWTO: Render partial in div
Hey- I''m using ROR 1.0 and script.aculo.us 1.5.1. I''ve been trying unsuccessfully to render a partial in a DIV, but can''t seem to get the right combination of stuff to make it work. There seems to be a few different ways of going about it. Right now I can render a partial. What do I need to to render the partial in a div? Here is what it looks like so far: #
2006 Mar 31
6
Adding objects to a :through association
So I''m one of those nasty people building a self-referential habtm-like Association using the funky new :through stuff. This is about users having friends, so here''s my user.rb: class User < ActiveRecord::Base has_many :friendships, :foreign_key => ''user_id'' has_many :friends, :through => :friendships, :source => :friend end And here''s
2006 Jul 10
18
Deleting join association of has_many :through
I''m trying to use has_many :through, since my join model deserves being more than just an intersection table. But when I try to break the association, the break only seems "temporary": Let''s say my two tables are Users and Colors, and the join model is Favorites. user = Users.find(1) user.colors.length >> 2 c = user.colors.first >> #<Color:....>
2005 Nov 21
2
Multiple user_id columns
I have a table called ''users''. I have a second table called ''comments''. The comments table is in need of _two_ columns that both reference different user ids within the ''users'' table (one column for the user id that originated the post, another column for the user id for which the message is intended for. Obviously I can''t create
2006 Feb 26
3
Representing relationships between model objects
I''m a little stumped on how to approach the subject of representing relationships between a single model object. Basically, I want a User to be able to mark others as Friends, Contacts, etc. The caveat is that User A can mark User B as a Friend but that doesn''t mean User A is marked as a friend by User B. It can either be a one-way relationship or two-way relationship. Right
2006 Mar 07
6
fcgi dispatcher crashing
I''m trying to set deploy an app on apache2 with the fcgid module, but can''t seem to get anywhere. Things work fine with cgi, but when i switch to fcgi, i''m stuck with a ''503: Service Temporarily Unavailable''. There''s no error being logged anywhere, afaik. Trying to run dispatch.fcgi from the shell doesn''t work either. It bombs out,
2006 Mar 31
2
"Owning" a polymorphic
I''m playing around with RoR and I''m having trouble figuring out how to describe a certain relationship. I''m building a social networking site where you have users who can comment on other users, photos, videos, and blogs. I''ve figured out how to have a comment belong to a user or media item through a polymorphic relationships but I dont'' know how to