similar to: last stupid question today

Displaying 20 results from an estimated 2000 matches similar to: "last stupid question today"

2006 Mar 21
3
Newbie - ActiveRecord relationships
So I''ve worked through Agile Web Development with Rails and I''m now trying my first little app to get into the swing of things. Its a task tracking app where people can create tasks and assign them to others, and also log time against the tasks. I''m having trouble working out the model relationships. This is what I''ve got so far, but its not right as
2006 Jan 19
0
Help with nested HABTM relationship
Hi, I am trying to perform a query with ActiveRecord that I want to put into a Rails application later. For now I just wrote it within a plain old Ruby script for easier testing. I am working with an existing database so I had to map some foreign keys myself. As you can see from the models below, the database has a structure of Prospectlists <=habtm=> Contacts <=habtm=> Accounts
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
2007 Jan 03
3
Self-referential habtm with condition is broken
Here''s a simplistic model class. class Person < ActiveRecord::Base has_and_belongs_to_many :relatives, :class_name => ''Person'', :join_table => ''relatives'', :foreign_key => ''from_id'', :association_foreign_key => ''to_id'' has_and_belongs_to_many :brothers, :class_name =>
2006 May 16
4
Problems with multiple ''id'' columns in a join_table
I have a problem declaring a relationship through a join_table ; the SQL generated by ActiveRecord is correct, but there are two columns called ''id'', and the final object gets the ''wrong'' column ... Here''s a more detailed description of the data, code, and problem :- There''s a People table, with id, name, and a few things. Also a
2005 Oct 05
0
has_and_belongs_to_many on legacy DB
I am working with mapping ActiveRecord onto a legacy database. All is going well (using set_table_name, set_primary_key, etc), but I can''t get my many<=>many relationships to work. My contrived example of the situation: Student has_and_belongs_to_many Teachers. This is mapped via table student2teacher where the foreign keys are studentId and teacherId. The primary key in Student
2007 Nov 30
0
cross sell products - Options_from_collection_select ?
Hi I have collected some code for cross sell products on this website. CREATE TABLE products ( id INT NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL, PRIMARY KEY (id) ); INSERT INTO products VALUES (1, ''alpha''); INSERT INTO products VALUES (2, ''beta''); INSERT INTO products VALUES (3, ''gamma''); CREATE TABLE cross_sells ( product_id
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
2006 Jan 06
2
Re: Some advice on DB modeling
I have more or less the same problem. I''m trying to build a system where users can enter their friends. But the solutions seems not to work for me. I used same sql: CREATE TABLE `friends` ( `user_id` int(11) NOT NULL default ''0'', `friend_id` int(11) NOT NULL default ''0'', KEY `user_id` (`user_id`), KEY `friend_id` (`friend_id`),
2006 Feb 21
3
HABTM :insert_sql help
Hi all, I''m working with a legacy sqlserver db and I''m trying to override the insert sql in as defined in the HABTM method below(becasue the join has three primary keys), but I''m getting the error: ''undefined local variable or method `record'' for Project:Class'' has_and_belongs_to_many :people, :class => ''Person'',
2007 Jul 26
1
Bi-directional self-referential HABTM
Hi, I''m having a little trouble figuring out how to make a self- referential HABTM bi-directional. I have a Employee class. Each employee can have a couple of bosses, who are also employees. The employee class has the following HABTM: has_and_belongs_to_many :bosses, :class_name => "Employee", :join_table => "bosses_courses", :association_foreign_key =>
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
2006 Apr 03
1
has_many :trough with 2x the same table
I have a site where Users can become Friends with other Users. I used to do this with a habtm, but of course I want to stay up-to-date and convert this to a has_many :trough. Unfortunately I can''t get it to work.. the documentation on this feature is a bit sparse at the moment. This is my old habtm: has_and_belongs_to_many :friends, :join_table => ''user_friends'',
2005 Aug 19
2
data validation
I''m trying validate date before they''re stored into the DB, but it seems, validation doesn''t work.. my model looks like this: class Company < ActiveRecord::Base has_many :contacts, :foreign_key =>''company_id'' has_and_belongs_to_many :categories, :join_table => ''company_to_category'', :foreign_key =>
2006 Jan 12
0
HABTM with conditional field in relation table
Hi all I have members in my application, and every member can assign other members as buddies. class Member < ActiveRecord::Base # Hat folgende Buddies has_and_belongs_to_many :buddies, :class_name => ''Member'', :join_table => ''members_have_buddies'',
2009 Mar 23
2
Select updates database?
I am running on Rails 2.2.2 on Solaris (and also on my mac) against mysql. For some reason, when I use a select in the partial, the database does not get updated with the changed value. I am using checkbox for other fields which works perfectly. I can provide more information if needed, but I would like the field to work as a dropdown instead of a text field. My Model:
2006 Jul 10
10
has_many :through and foreign key parameters
I just took my HABTM and turned it into a :through since my join table has another "non-joiny" attribute. I went from this: has_many_and_belongs_to :jobs, :join_table => ''tablename'', :foreign_key => ''x'', :association_foreign_key => ''y'' to this: has_many :jobs, :through =>
2006 Mar 05
1
Help with Self-Referential HABTM
With the help of the Rails Recipes have got a self-referential HABTM relationship working, but I''m really struggling with getting a new entry from a form accepted. i should say here that the form is also submitting info for the join table too. So in my model I have: class Type < ActiveRecord::Base has_and_belongs_to_many :subtypes, :class_name => ''Type'',
2006 Jan 19
5
limits of has_and_belongs_to_many
I''m experimenting with Rails on the Recipes example first before I dive into applying it to my intended application. I''m exploring which will be more work: to rename all the primary id''s in the legacy database, or to work around the fact that the primary id''s are not called ''id'' within RoR instead. I''ve been successful in using a
2006 Jul 12
0
two-way dictionary
Hi! I''m working on a multi-language idioms mapping application in which an expression object has a habtm relation with its own class. I thus created a table ''expressions_dictionary'' and would go about by declaring something like: has_and_belongs_to_many :peers, :class_name => "Expression", :join_table