similar to: habtm vs. has_many/belongs_to

Displaying 20 results from an estimated 2000 matches similar to: "habtm vs. has_many/belongs_to"

2006 Mar 30
5
Has_many :through problems -- please help
I''m having a lot of trouble with has_many, :through and could really use some assistance. I''ve got a User and Group class. Users can subscribe to groups, and groups should know who''s subscribed. I''ve got a join table (group_subscriptions) with group_id, user_id, and it''s own id element. Users has "has_many :groups, :through =>
2006 Mar 15
5
Passing params to a component
I see from http://rubyonrails.org/api/classes/ActionController/Components.html that is possible to pass paramaters to a component. I don''t understand the exact syntax. I''m trying: @master_id = @params[''master_id''] in the components controller but it is not working. ==== Details: In my calling view I have: <%= h(@opportunity.id) %> <div
2006 Mar 16
2
WEBrick and OS X 10.4.5 problems?
Has anyone who is running OS X 10.4.5 and the security patches thereafter noticed that WEBrick is no longer functioning? I have a machine at school that I believe to be patched with 10.4.5 but not with the latest security patch and WEBrick seems to run fine for it. However, on my machine at home I can''t get WEBrick to successfully run even freshly generated apps. For both
2006 Jan 25
2
Update join_table attributes
I have two ActiveRecord classes that point at each other with a "has_and_belongs_to_many" (habtm) relationship using a join table. The join table has an a few additional columns besides the _id columns. For those of you with the Agile Web Dev w/ Rails book, it''s exactly the same setup as the articles<->articles_users<->users example on p240. The habtm
2006 Feb 16
1
HABTM -VS- belongs_to/has_many, for self-referential joins
Ok, David says on page 241 that sometimes a many-to-many relation with attributes are better implemented as an actual model instead of using HABTM. Well, I''ve got that situation and I can''t figure it out. All of the examples in the book have HABTM examples between 2 different tables, but I want to have a HABTM relation on 1 table with itself. (e.g., if I have a table Things,
2006 Mar 15
3
App design help for a newbie (trying again)
Hi there, I''m working on a new student portal system using Rails for a large university. As part of this application, I plan on students being able to customize their own calendar, collection of commonly used links, aggregation of newsfeeds (from the university, student groups, etc), and to see a listing of major announcements they should be aware of. It seems to me, to make the most
2006 Apr 21
2
Forms Containing Collections problem
Can anyone tell me why I''m getting the error "The error occured while evaluating nil.id_before_type_cast" for the following view code <% for entry in participant_portfolio.portfolio_entries -%> <%= select "entry[]" , :id, @buyer_profiles, :selected => entry.buyer_profile_id %> <% end -%> This seems to only happen when I use
2006 Apr 18
1
habtm and belongs_to one table
I have the following: Posts belong to a User Posts may be Monitored by many Users How do you characterize this? class Post < ActiveRecord::Base belongs_to :user has_many :monitors class Monitor < ActiveRecord::Base has_many :posts, :as => user class User < ActiveRecord::Base has_many :posts # when a user *does* a post belongs_to :monitor, :polymorphic => true --
2007 Oct 11
1
HABTM and has_many through only work in one direction
I have two models that have a habtm relationship and it only seems to be working in one direction. The two models are "recipe" and "msn_lifestyles_feed" with a join table called "msn_lifestyles_feeds_recipes" the tables for msn_lifestyles_feed and msn_lifestyles_feeds_recipes are in the same database and the recipe table is in a completely different database. When
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 20
0
habtm has_many through and foreign keys
I have two models Role and Task ..and a join table/model RoleTask Now both roles and tasks have id as a primary key and name which is a unique identifier I want the join table to hold role_id and task_name I''ve tried using habtm with foreign key and association foreign keys set up and I''ve tried using has_many :through ..but they all seem to someone want to work with the
2007 May 04
1
habtm and also has_many of the same things
Hi, our app is a situation where users can upload files and also mark files uploaded by other users as their favorites. So for the favorites we are using a simple many-to-many with a tie table. So in attempting that it looks like class User < ActiveRecord::Base has_and_belongs_to_many :media_file has_many :media_file end class MediaFile < ActiveRecord::Base
2007 Oct 15
0
converting from HABTM to has_many :through
Hello, I have a has_and_belongs_to_many relationship that I''ve realized I need to add additional attributes to. So I''m converting it to a has_many :through (HMT) relationship. This is the first time I''ve used an HMT, and it seems like I''m using too much code. I couldn''t figure out how to get the join model objects to update automatically as a result of
2006 Apr 03
0
has_many questions
My application has two models I''d like to have multiple join tables between, Users and Groups. Users have the ability to subscribe to a Group, while a Group would like to know its membership. Additionally, a User can administer several Groups and a Group should know about its several Administators (Users). I have the following declarations: class Administrator <
2009 Jun 22
5
has_many through , or habtm , using form
i think there ara two ways of relate products and categories , basically i want to fix one product(e.g hp dv7....) to some categories (notebook,17"notebooks...) i made a table named categorization(incuding category_id,product_id fields) then in models i write these codes below class Product < ActiveRecord::Base has_many :categories, :through => :categorizations
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 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
2012 Aug 13
10
Question about PATCH method, accepts_nested_attributes_for, and updates to association lists (has_many, HABTM)
Am interested in the new PATCH method that will be included in Rails 4, but have a question/concern, and forgive me if I''m misunderstanding it. So, if the request parameter _method is set to "patch", the update is processed as a patch. But, let''s say you have a model called Airplane and Airplane has a collection of FlightCrewMembers which it
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 Mar 13
3
HABTM: two habtm''s between the same two tables
Imagine I want to track people, and the clubs that they belong to. table people with columns person_id, person_name table clubs with columns club_id, club_name And I have the association table: table clubs_people with columns person_id, club_id Now I know how to do this habtm between the two, in order to associate people with clubs that they belong to. However my application also needs a