similar to: issues with relationships and multiple objects on one form

Displaying 20 results from an estimated 4000 matches similar to: "issues with relationships and multiple objects on one form"

2006 Feb 24
4
Problem having two belongs_to of the same class type
I have a Shipment class that is used to ship packages between Branches. However, when I try to have two belongs_to in Shipment called shipped_to and shipped_from I can''t seem to make it work. I can get it to display the form properly but when I select the branches and click save I get the following error... "Branch expected, got String" Any ideas? I have added some code
2005 Jul 25
2
acts_as_tree and traversing parent/child relationships
I am working on an Rails application that uses a pretty complex category structure through out the site. I have defined a table to house all the info and a FK to reference parents within the table CREATE TABLE categories ( id int(11) NOT NULL auto_increment, name varchar(50) NOT NULL, parent_id int(11) default NULL, constraint fk_category_id foreign key (category_id) references
2006 Mar 25
0
Self-Referential Many-To-Many relationships where the relationship itself has data.
Trying to model a bunch of users that have friends that are other users. clearly a job for has_and_belongs_to_many, but the trick is, they have ratings for their friends. I have gone through the Rails Recipes book, and it seems like I''m trying to combine the self-referential many-to-many recipe (12) and the many to many relationships where the relationship itself has data recipe (16). So
2008 Nov 20
3
Any progress on undirected self-referential many to many relationships?
I am going to re-ask a question that has been asked a few times in the past. What is the best way to represent an undirected self-referential many to many relationship. Trivial examples of this include an edge in an undirected graph, or a mutual friendship. Alice is a person Bob is a person Alice and Bob are friends of each other We have a whole bunch of extra information about their friendship
2007 Apr 20
0
problems returning collection_select info to controller
Hi, I''ve been working with rails for a couple of months now and I''m beginning to understand how things work but this has got me baffled. I want to return the user.id from a selection of a list of user names. I followed the example from AWD w/ Rails (page 487) on how to use collection_select but the controller barfs because it wants a user and the id is coming back as a string.
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:
2006 Mar 31
3
Complex Through Statement
Quick Overview: I have an ''Employee'', some ''Merchants'' and some ''Products''. A ''Merchant'' has many ''Products''. An ''Employee'' has multiple ''Merchants'', depending on their relationship. For example, the Employee may be the enrollment contact for one merchant and the
2006 Feb 09
6
Can I protect access to a relationship?
Hi, I have a class Match that looks like this (simplified) class Match < ActiveRecord::Base belongs_to :opp1, :class_name => "Player", :foreign_key => "opp1_id" belongs_to :opp2, :class_name => "Player", :foreign_key => "opp2_id" belongs_to :winner, :class_name => "Player", :foreign_key => "winner_id" end Can I
2006 Jan 19
5
Multiple HABTM relationships with self ???
I need to have a table related to itself via a join table. Will HABTM support this? That is: class Recipe < ActiveRecord::Base has_and_belongs_to_many :recipes, :join_table => "recipes_recipes" end More importantly -- how does RoR support MULTIPLE self-joins? I.e., to relate the table to itself via multiple join tables. SFAIK, HABTM won''t support multiple
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
2013 Feb 08
1
Problem with many to many relationship
Hi I''m trying to create a many to many relationship between two models. A User can be associated with many Incidents and vice versa. class User < ActiveRecord::Base include ActiveModel::ForbiddenAttributesProtection has_many :incident_participants, foreign_key: "participant_id" has_many :participated_incidents, through: :incident_participants end class Incident
2006 Mar 29
3
Self-referential many-many joins with :through
I thought I had this nailed but.. now I''m seeing spots.. I''ve included my models below, feel free to ignore them. I''m really just after an example that works. I couldnt find one on the wiki... which is fair enough considering Ricks patch: http://dev.rubyonrails.org/changeset/4022 that fixed them only went through 5 days ago.. Cheers -henster
2009 Apr 16
0
Magic multi connections with association problem
Dear all I am using magic multi connections, there is some problem when using association. How can I dynamic determine the module name (i.e. A::Request, B::Request) in activerecord association. Below is my code: module A establish_connection :A end module B establish_connection :B end # and many module.... class Request < ActiveRecord::Base set_table_name "request"
2006 Oct 22
3
Keeping DRY - I like a simple life!
Hi, I''m new to Ruby and Rails and I would be very grateful for some advice. I''ve got the following code. class Foo < ActiveRecord::Base include Versionable # Some methods to handle my versioned objects has_many :versions, :class_name => "FooVersion", :foreign_key => "parent_id" belongs_to :curr, :class_name => "FooVersion",
2006 Sep 22
2
possible to create polymorphic relationship with STI models?
I would like to associate a ‘product’ model with 3 models inherited from ‘image’: part, action and accessory. I have it working with Has_many :through relating products to images through attachments, I then have to determine the ‘type’ of the STI extension. This means i have to go product.images. While this is ok, i can see it getting tricky when i want to go products.images <<
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 Apr 25
3
belongs_to and has_many
I know this has been rehashed many times, but I don''t get it. I can''t find it documented to were I understand all the parts. I can make this work using Rails database design conventions, but in this case I am not able to do that. I find examples, but the ones I find do not follow the conventions. They also do not give enough information to understand what is going on. In
2006 Jun 14
0
Mssql Multiple Database Access Error
Hi All, I am having a problem to access multiple databases with mssql I am running Ruby 1.8.4 and Rails 1.1 on Windows 2000 Advanced Server. I am simply trying to integrate the application I wrote before for Oracle to Mssql. The application works perfectly with Oracle with the installed driver OCI8. The app retrives data based on a search criteria from those databases. I followed the directions
2006 Jun 27
2
how to use scope with acts_as_list
i am working on a task management system for the company i work for. i just got the rails cookbook and am trying to use the section on creating a drag and drop sortable list. the tricky part is that my Task model references the User model in two different spots. i have one field for the creator of the task and another for the assignee. so in my Task model i have the following code: class
2006 Jan 22
2
suggest for "ambiguous column" when JOIN associated tables
Today I face with incorrect behavior in ActiveRecord. It take place when I try to use :include parameter for .find method. Where are two typical cases: 1. You have record with self-referential joins CREATE TABLE keywords (id, group_id); class Keyword < ActiveRecord::Base belongs_to :group, :class_name => "Keyword", :foreign_key =>