search for: has_and_belongs_to_mani

Displaying 20 results from an estimated 441 matches for "has_and_belongs_to_mani".

2006 Apr 16
6
still learning maintaining data with join tables
Class Role has_and_belongs_to_many :users Class User has_and_belongs_to_many :roles Class RolesUsers has_and_belongs_to_many :roles has_and_belongs_to_many :users According to the logs...I''m good through here @roles_users = RolesUsers.find(:all, :conditions => ["user_id = ?", params[:users_id]] ) the next section of controller code is a problem...
2005 Mar 01
0
has_and_belongs_to_many problem
I''m having a problem with a has_and_belongs_to_many (habtm) association between two models with extra attributes. I''m writing a comic book database, and each issue has many creators on it. Thing is, some creators perform multiple duties. They may write one issue, draw another, etc. However, if I add a creator twice to an issue and try to delete it, it removes both creators:
2006 Feb 28
8
HABTM count table
Hello, I have a question about HABTM and counting records. I have these models class Sort < ActiveRecord::Base has_and_belongs_to_many :reports end class Report < ActiveRecord::Base has_and_belongs_to_many :region has_and_belongs_to_many :subjects has_and_belongs_to_many :sorts end And i would like to get a count like @sort.reports.count The problem is get this query:
2006 Mar 20
2
AHHHhhhhh... has_and_belongs_to_many, that is going on?
I don''t have a class by the name of "ReviewersScoreCard", yet my many to many configuration looks as follows. And, these errors while running some simple test with ./script/console is giving me a headache: ./script/console Loading development environment. >> r = Reviewer.find_first => #<Reviewer:0x19d0a48 @attributes={"id"=>"1",
2006 May 11
1
ActiveRecord collection_select and has_and_belongs_to_many
Hello everyone, first post to the list and a relative newbie to Rails development. Done quite a bit of JSP, PHP, HTML, XML etc and thought I would kick the tires on Rails to see if it can speed up development for internal applications. Anyway, I am running into a problem that is just driving me crazy and everything I read on the net doesn''t seem to help. I was hoping someone here might
2006 May 08
2
Queries with has_and_belongs_to_many relationship
I was able to create a has_and_belongs_to_many relationship for my app, but now I''m not too sure how to write queries for it. Basically, I have a table ''courses'' that has_and_belongs_to_many ''categories'' and vice versa So I''m trying to figure out how I would find only the courses that belong to a category that I specify. Let''s
2006 Apr 06
3
has_and_belongs_to_many find
Say I have a post model that has_and_belongs_to_many :categories, and a category model that has_and_belongs_to_many :posts. So I have a categories_posts table to do the join. That''s all find and dandy. However I want to be able to find all the posts that belong to a specific category. I tried Post.find_by_category(:id) but that doesn''t work. Does anyone have any insight?
2006 Aug 16
1
Naming rights_roles join model using has_many :through and polymorphic associations
Hi. I have a couple of best practices questions regarding polymorphic associations, naming join tables and user permissions. Currently I have implemented the user authentication model from the rails recipes book. Basically it goes something like this: MODEL CLASSES: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role < ActiveRecord::Base
2006 Feb 26
5
Help On Associations Extension.
Hi to all, I''m needing some help here ... I want to do an extension on a has_and_belongs_to_many to build a custom add method to the association. i have a table locations that has a many-to-many association with a tags tabel using a locations_tags table. i want to add a method to the Location has_and_belongs_to_many association so that i can do something like this on the location
2012 Sep 08
3
Polymorphic has_and_belongs_to_many association
Hi, I''m currently having the situation where I have to implement a polymorphic has_and_belongs_to_many by introducing an in between model that handles all the "has_many :as" and "belongs_to :polymorphic" association implementations... and is not doing anything else. Thing I don''t like it here is, I am unnecessarily loading AR instances only to execute SQL
2012 Sep 12
2
how to generate third table in test database
hi all, has_and_belongs_to_many :cows has_and_belongs_to_many :milkmans i am using has_and_belongs_to_many in my app.I know this will create third table internally cows_milkmans in mysql database. when i migrate develpoment database i have table cows_milkmans. Good no Problem till now. Now a problem start When i migrate test database there is no such cows_milkmans table is present..
2006 Aug 16
3
Question RE Rails associations
Hi, I am new to Ruby and Rails programming and am having difficulty with the following scenario... Consider the following model: class Studio < ActiveRecord::Base has_many :movies has_and_belongs_to_many :actors end class Movie < ActiveRecord::Base belongs_to :studio has_and_belongs_to_many :actors end class Actor < ActiveRecord::Base has_and_belongs_to_many :studios
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
2005 May 23
1
has_and_belongs_to_many dual insert error ?
Hi ! (See references at the end) I have a slight problem. Whenever I save one of my domain models, which contains an has_and_belongs_to_many relationship with another one, the relationships are doubled. My domain is a series of pictures, where each picture can be tagged with one or more words. So, a picture of my dog could be tagged "Jordy, Dog, Dog 2005", for example. In my
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 Apr 03
3
Read Only Error Since 1.1?
Since I upgraded to 1.1, I am getting ''ActiveRecord::ReadOnlyRecord'' exceptions when trying to save a specific record. I read up on ActiveRecord::Base.readonly? but I don''t think the condition there (objects pulled in from a certain JOIN type) applies. Here''s my code that is throwing the exception: @company = session[:company] @company.bytes_used =
2006 May 26
0
has_and_belongs_to_many with fk constraints?
Hi folks, I''m wondering if it''s possible to use foreign key constraints on the join tables of a has_and_belongs_to_many relation. Specifically, I get this error when I try and delete a model I''m using, named saved_search, which is many-to-many with neighborhoods. Any ideas? Thanks for any help. :-) -Eric Code: @saved_search.destroy Error: Mupdate or delete on
2006 Jan 13
2
newbie: access model inside a model
Hi everybody, I''ve started to learn Ruby on Rails with the two books, of course I''m experimenting outside the examples in the book and walking against some things I didn''t learn yet. so here''s the question: Is it possible to access one model from within another? Actually I have a Many to Many relationship between tables and I''m trying to realize
2006 Jan 16
0
belongs_to with has_and_belongs_to_many
I''m having a problem with belongs_to and has_and_belongs_to_many. Here''s a brief summary of the models involved: class Member < ActiveRecord::Base set_primary_key ''member_id'' has_and_belongs_to_many :projects, :join_table => ''projects__members'' has_many :projects, :foreign_key => ''created_by'' end class
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