Displaying 20 results from an estimated 4000 matches similar to: "Find sub sub records"
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
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
=>
2007 Jan 25
1
has_and_belongs_to won't delete records
Hi,
I have a has_and_belongs_to relationship between 2 objects, order and
product. I''m getting a foreign key violation when trying to delete
Order. Is there a special way of deleting orders without deleting
products? ("has_many" has :dependant => :delete_all.... does
"has_and_belongs_to" have something similar)
Trying:
Order.delete_all
Getting:
Mysql::Error:
2006 Apr 14
1
ActiveRecord and multiple associations
Hello,
I have a Company that has_and_belongs_to_many Persons. A Person
has_many Emails. I want to display each Person''s Email for each
Company, so I try this:
companies = Company.find(:all)
for company in companies
persons = company.persons
for person in persons
puts person.email
end
end
Unfortunately, this doesn''t work correctly. Let''s say the id of
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 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
2005 Jul 07
3
NameError Exception
Ruby/Rails n00b here so go easy on me...
I''ve been wracking my brain trying to figure out what is wrong here.
I''ve checked all my models for the appropriate belongs_to, has_many,
etc. I''ve checked to make sure I''m using singular and plurals in the
right spot. I''ve checked my syntax around all my "within"''s and nothing
seems to fix
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 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...
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 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
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 Nov 16
1
HABTM: deleting records based on attributes
Hello All,
I am new to ROR, and can''t seem to get HABTM to cooperate entirely...
however I might be abusing it! Before I try a different strategy I
thought I''d ask here and see if I''m missing something simple.
So say Projects and Companies are related. Projects can have multiple
Companies, and Companies can be on multiple Projects. But, the same
Company can also
2006 Feb 15
4
problem with saving id''s in a join table
hello,
I''am new to ROR and I have a problem.
I have to models "rights" and "roles" on a has_and_belongs_to_many
relationship, through "roles_rights" table. When I try to add a new role
although I put in my form fields for each right, a record is added to
table roles but none to roles_rights.
I am using Ruby 1.8.4 rails 1.0 mysql 5.0
here is my code:
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 18
3
Model Madness: habtm vs through
This has me scratching my head:
a Person has many Things
a Person has many Collections
a Collection has many Things
...Things in a Collection are ordered
...Things in a Collection can be related to (created by) any User
...a collection has additional attributes, such as a name etc
I am confused about habtm in rails (especially when using
acts_as_habtm_list) vs. going the :through route.
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
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?
2009 Oct 08
3
[PATCH] fix storages crazyness
Signed-off-by: Loiseleur Michel <mloiseleur at linagora.com>
---
app/models/vm.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/app/models/vm.rb b/app/models/vm.rb
index 88e0aef..0be3f89 100644
--- a/app/models/vm.rb
+++ b/app/models/vm.rb
@@ -27,7 +27,7 @@ class Vm < ActiveRecord::Base
find(:all, :conditions=>{:state=>Task::STATE_QUEUED})