search for: hasmanythrough

Displaying 20 results from an estimated 232 matches for "hasmanythrough".

2006 Jul 04
2
has_many working correctly only on reload!
I have this code that is using svn externals with rails EDGE working fine for the past couple of months. A couple of days ago, this code died. Even after deleting vendor/rails, this code doesnt work: class Tag < ActiveRecord::Base has_many :taggings has_many :events, :through => :taggings has_many :users, :through => :taggings end class User < ActiveRecord::Base # Virtual
2006 Jul 21
2
New Generator: hasmanythrough
...t everyone). I''ve created a new generator that generates two model classes, plus a many-to-many relationship class, e.g. User, Group, plus the Membership model between them. It also generates the migrations and a set of unit tests. I''ve tried to write this all up here: http://hasmanythrough.rubyforge.org/ Let me know if this is useful and/or what can be improved (and what extra unit tests can be added). Cheers Dr Nic -- Posted via http://www.ruby-forum.com/.
2006 May 21
3
has_many :through with a polymorphic join
Hi, Four tables: users, user_counties, uk_counties and us_counties. Each user has many counties, and each county has many users, so I decided to make user_counties a polymorph, so it can have counties from different countries (each country requires a completely different set of tables with a completely different set of properties, that''s why there''s one table for uk_counties and
2006 May 28
7
Join table not being populated
Hello, I have the usual Categories and Products table scenario, mediated by a Categories_Products join table. When I create a new Product and into a given Category, I notice that my join table is not being populated. Shouldn''t the join Categories_Products table be populated? Thanks, gk -- Posted via http://www.ruby-forum.com/.
2006 May 10
7
has_many :through scope on join attribute
Hi I have a has_many :through. It''s a basic mapping of Project id .... User id .... TeamMembers project_id user_id role What I would like to do is have different roles so I can have in the project model has_many :core_members, :through => :team_members, :source => :user but I would like to limit this to only those with the "core" role in the team members table for
2006 Jul 10
7
What is has_many :through really buying you over HABTM?
...oaches. 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 your joined tables. [ Actually, now that I read the dance-off blog (http://blog.hasmanythrough.com/articles/2006/04/20/many-to-many-dance-off) again, perhaps the other problem is HM:T is better at handling polymorphic has_many associations? ] Still, in a simple case, it seems like you could have a HABTM relationship between two tables that would co-exist with a separate model on the joi...
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 23
5
Dirt simple .rcss templates
...about doing .rcss templates in Rails using a custom template handler. I''ve come up with a very simple way to support rcss without a handler. Turns out all it takes is a route and an action that calls render(:file...). I put a full write-up on my blog earlier today: http://blog.hasmanythrough.com/articles/2006/03/23/dirt-simple-rcss- templates Of course if anyone sees a simpler way to accomplish this, I''m all ears... --josh http://blog.hasmanythrough.com
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 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 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 Apr 13
2
Content-type on render :file
Hi all, I''ve just been trying out the dirt-simple rcss scheme posted here: http://blog.hasmanythrough.com/articles/2006/03/23/dirt-simple-rcss-templates It looks like the content-type declaration on the line: render :file => file_name, :content_type => ''text/css'' isn''t getting honoured. I had to add a separate: @headers[''Content-type''] =&gt...
2006 Mar 22
5
Adding Custom templates?
Hi, does anybody have any pointers on where to look to learn how to write custom dynamic templates? Agile is a little sparse on this (but otherwise superb)! Thanx -- Posted via http://www.ruby-forum.com/.
2006 May 28
7
Self-referential has_many :through relationship
...erything works great except the last potential_friends line. It seems unable to figure out to use the friend_id foreign key. I have tried to specified the :source param according to the docs. Am I missing something here? The exact error is: >> User.find(1).potential_friends ActiveRecord::HasManyThroughSourceAssociationNotFoundError: ActiveRecord::HasManyThroughSourceAssociationNotFoundError from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/reflection.rb:173:in `check_validity!'' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/activ...
2006 Jul 05
7
HABTM join table has an "ID" column - is this an issue?
All, I''m building model objects for existing tables that I cannot modify. In AWDWR, Dave says "Note that our join table has no id column...The second reason for not including an id column in the join table is that AR automatically includes all columns from the join tables when accessing rows using it. If the join table included a column called id, its id would overwrite the id
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 Jul 15
2
find() with id array - can i preserve the ordering?
Sort of a newbie question - sorry if it''s been asked before and I missed it in my search. I have an id_array of Author ids, and I want to retrieve the associated Author models as quickly as possible, but also preserve the ordering of the id_array. Using Author.find(id_array) returns the records, but not in the same order. Is there some flag I can pass to find() to preserve the order? I
2006 Jun 27
3
Trunk or 1.1?
If you were launching a site in late September, would you be developing with Rails 1.1 or on edge rails? Joe
2006 Apr 01
3
has_and_belongs_to_many construction
Hi there, I''ve got a table construction like this: presentation contactstate Hilton new Mc Donalds emailed etc. called visited etc. Now i''ve created an join table presentationcontactstate with extra fields like comment and date time. so i know for example when i called a specific presentation. Now
2006 Jun 29
3
stylesheets
hi, all i have been playing around with rails for sometime, i have seen most not all of the rails sites have similar look and feel (good one) i want to know how to use the stylesheets provided by the RoR framework if any or is it that we have to define on our own from scratch. basiclly i need information regarding how can i make my view better looking(the visuals) Thanks in advance warm