similar to: A simple, short model naming question.

Displaying 20 results from an estimated 8000 matches similar to: "A simple, short model naming question."

2006 May 06
3
Storing additional data on join tables with Rails
Hi there I need to store additional attributes on join table. Searching the Wiki [1] revealed two possible methods: 1) push_with_attributes, as described by Justin Palmer [2]. Unfortunately, "this method is now deprecated" [3]. Even if it wasn''t, there seem to be inherent problems with that approach, for example with updating those additional attributes, though Joshua Muheim
2006 Jul 10
7
What is has_many :through really buying you over HABTM?
So having just learned how to do has_many :through as opposed to HABTM, and then, being concerned that I wouldn''t get it to work, I started thinking about these two approaches. It seems to me that the _only_ problem that the HM:T (has_many :through) approach solves that HABTM doesn''t is the issue of the potential collision of id columns between your join table and one of
2006 May 27
7
How should I select rows from a join-model based on more than one association?
A concrete example: We''re building a system to organize the information about workshops being held in various conventions. A convention has more than one workshop, and each workshop can be held in more than one convention. Also each workshop has a host, who is specific to a workshop being held in a specific convention. For example, Matz may host an "Introduction to Ruby"
2006 Jun 05
7
Is HABTM Dying?
For a while, I''ve been getting that HMT is replacing HABTM. It appears that HMT can do all of what HABTM can do and more. The question is: Should I stop using HABTM? Let''s take a simple case: A case has many categories For a given category, there are certain valid statuses Category has_and_belongs_to_many :statuses Status has_and_belongs_to_many :categories Question: Is
2006 Apr 23
0
Severe STI, HABTM with Attributes and 1.1
All, I had been working on a project that was using STI to a very high degree. It also was using a HABTM table that had a couple extra attributes. It seems that with 1.1 push_with_attributes is deprecated and I am having a bit of trouble moving things to using has_many :through The original schema I had worked like this : create_table "nodes" do |t| t.column "title",
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
2006 Jun 21
0
how to save objects associated via has_many :through?
I recently converted a habtm relationship into one using has_many :through. Some of my old logic relied on the ability to use the #<< operator to add items to the relationship and get them auto- saved. I''m curious to know the best way to do the same operation with the has_many :through configuration. I looked through the list archives and didn''t find my answer.
2006 Jun 22
0
how to save objects in a has_many :through association?
(I posted this yesterday but it never showed up on the mailing list... weird.) I recently converted a habtm relationship into one using has_many :through. Some of my old logic relied on the ability to use the #<< operator to add items to the relationship and get them auto- saved. I''m curious to know the best way to do the same operation with the has_many :through
2006 May 31
6
habtm on an array (or object.habtm.habtm)
Hi, I have three Models: User, Group and File. User habtm groups and Group habtm Files How can I find all files that a particular user has access to? eg user.groups.files ? As user.groups returns an array, the above doesn''t work. Id like to find the files for all groups in that array, without adding any code to the User model. Thanks in advance PS I just posted this in the
2006 Jul 05
1
created_on in HABTM table getting parent dates
All of my HABTM tables receive the parent created_on/last_update_on dates whenever a record is inserted into these join tables. I don''t have any defaults in the database or anything else populating these tables. I assumed rails would populate these automagically. Is there something that needs to be done to get this to populate with the correct current timestamp instead of
2006 Jun 05
5
adding habtm through migrations
Hello, I''m stuck, I''ve got a model Product and would like to add a new model called Category. Furthermore, I want to set up a many2many relationship between the mentioned models. the problem is that I do not know how to set the primary key in the categories_products table. this is what I''ve got in my migration file: create_table :categories do |t| t.column :name,
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 Jul 12
1
odd habtm behavior? or is it me?
Hello List, I''m a bit spent on this problem, and my code might be whack. I seem to be encountering a problem where the primary key on a join table is not being resolved correctly. I will elaborate after some code bits. I am creating the join table using migrations, and relevant model code is this: class Post < ActiveRecord::Base has_and_belongs_to_many :records
2006 Apr 05
5
Updating attributes in HABTM association
Hi, I am trying to find a way tp update attributes in a habtm association. I am trying to use the code from ticket #2462, but as my association_class_primary_key_name seems to be empty the generated sql code is corrupt. I hope thats not a problem of my model that this variable is empty. What would you recommend to update those attributes (rails 1.1) THANKS!!! -- Posted via
2009 Aug 07
2
create separate plots by factors
Hello, I am attempting to create several plots based on "site" (~300 total) and am having trouble with the code. I simply want to create a plot using the code, plot(year, peak), for the following dataset. I would like for each site to be plotted on a separate page and the plots saved in a directory. Would a "foreach" loop work? I tried a "by" statement, but
2006 Feb 18
6
Naming join models
I''ve been playing around with EdgeRails and checking out some of the new features. The one that will probably have the biggest affect on my designs is join models (or :through associations). For those not familiar with this feature, it lets you replace your habtm association with a pair of has_many associations indirected through an intermediate model class. Looks like good
2006 Jul 10
4
HABTM vs. using has_many :through
All, I''ve heard recently about has_many :through as a necessary alternative to HABTM (when the join table has it''s own id column, say, in a legacy schema). However, is the prevailing Rails wisdom now that one should use has_many :through in _all_ cases? If so, why? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Jun 11
2
HABTM Duplicates?
Hello all, I''m working on a small Rails site for a game I play that will be used to add new characters. Part of this addition process is choosing what skills the character will have. For this, in MySQL, I have a characters table and a skills table, as well as a characters_skills table that is used as the join table in the habtm relationship between the two. I am presenting the skills in
2007 Oct 18
0
Getting the through items from a has_many :through :uniq relationship
Getting the through items from a has_many :through :uniq relationship In a nutshell, I have been using the has_many :through :uniq relationship, and I want a DRY way to list the join model objects. Currently, my objects include taxon objects, toxin objects, data_object objects, and taxon_toxin_citation objects ("citation" is another word for data_object). A taxon has many data objects,
2006 Apr 30
2
HABTM: Find sorted by number of associations
Hi, I''ve been googling and searching the forums for some time but can''t seem to find exactly what I''m looking for. Suppose User HABTM Products (for example a favorites list). I would like to construct a single query for finding Products ordered by the number of Users that have flagged them as favorites. Although I can construct the query using SQL a with a