Displaying 20 results from an estimated 20000 matches similar to: "HABTM and Belongs to find"
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.
2006 Feb 20
0
No Magic for HABTM forms?
Hi,
I posted yesterday asking how to get form tags to reference the
associated objects in a habtm relationship. I was hoping for Rails
Magic, but it looks like Rails doesn''t have habtm magic beyond a
certain point.
Here was my solution for others who might have the problem. Also, I
hope someone shows me that there is a simpler way.
The Database Model:
class Registration <
2006 May 23
2
HABTM for Dummies Question
Taking time off from programming is always painful :-).
I have the following Models:
====
class Tag < ActiveRecord::Base
has_and_belongs_to_many :problems
end
class Problem < ActiveRecord::Base
belongs_to :user
has_and_belongs_to_many :tags
end
====
And the following migrations:
====
create_table "problems" do |t|
t.column "user_id", :integer
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
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
2010 Aug 18
6
Once I added this HABTM, one of my 'through' relationships, on a non-habtm model, seems to have broke?
I''m a rails newb and have been Googling about this, but I''m still stumped.
Not showing everything here, but basically it should be a pretty common
setup so I''m sure others know what I''m doing wrong.
- A meter can belong to many meter_groups
- A meter_group can have many meters.
- A user can ''subscribe'' to viewing a meter_group (Subscription)
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 Jan 06
6
HABTM problem not saving all associations
Hello all,
I have an Order object that has and belongs to many Products and has
and belongs to many Loan Types. This is so I can select multiples of
each in my order entry screen via checkbox groups.
I''m having some trouble with saving multiple HABTM associations for a
single model object; only the first HABTM association declared in the
model will save during the initial @order.save
2006 Mar 28
3
Rails 1.1: Is HABTM obsolete?
Does the new has_many :through and belongs_to :through obsolete (well,
replace and essentially deprecate) has_and_belongs_to_many?
Joe
--
Posted via http://www.ruby-forum.com/.
2006 Jun 30
2
how to HABTM with STI ??
Hello all
This is my first post so excuse the basic question. (and any repeats I just
got an email saying this post was too big so I have re-submitted a smaller
version)
I was following the thread on
http://lists.rubyonrails.org/pipermail/rails/2006-May/038988.html regarding
the STI on HABTM for RoR.
I have a very similar problem and was hoping for some help.
I have the
2005 Jun 03
1
sorting on a habtm relationship
I have two tables ("products" and "categories") that have a
has_and_belongs_to_many relationship, and I need to be able to
arbitrarily sort products in the scope of a category using something
like acts_as_list. Problem is, since each product can belong to
multiple categories, it doesn''t work to use acts_as_list and have the
"position" field be in the
2010 Jan 20
0
need help with nested forms and habtm
Hi,
I''m currently stuck with a problem I just can''t find a clever solution
for. I checked every tutorial, issuetracker, API reference I could
find but found nothing to "enlighten" me --> I desperately need your
help :-).
My Question is: is it possible to use nested forms for habtm
associations?
--> Here some more info about what I wanted to do and what failed
2006 Jan 21
0
Display options from HABTM
I have a large certifications table that I would like to have a little
more controll over, it is part of a HABTM relationship.
-----------------------------------
db''s (simplified)
>certifications
id
course
>employees
id
department_id
type_id
name
>departments
id
name
>types
id
kind
>certifications_employees
certification_id
employee_id
2006 Mar 22
1
HABTM / Dropdown Help Needed
I''m terribly new to Rails, so bear with me.
I have an application I am working on which deals with projects and
subcontractors. There can be several subs on each project and each sub
can work on several projects. I have my join table set up and
has_and_belongs_to_many in both models. If I manually put data in the
join table, this works in my show view:
<% for subcontractor in
2009 Oct 20
2
Find sub sub records
Hi everyone, I have the following problem, maybe someone can help me
figure out what to do.
To simplify my situation, I''m going to make an example of what I need,
this is not the real app structure.
Let''s suppose we have three models, Library, Author, Book.
Manager
has_and_belongs_to_many :area_managers
AreaManager
has_and_belongs_to_many :managers
has_many :employees
2009 Oct 04
1
circular relationship - habtm
So I have 2 models: Picture and Comment.
Pictures have many Comments, but I''d like for users to be able to post
Pictures in Comments, so Comments will have one Picture (possibly).
This creates a kind of circular relationship it looks like, and the
only way I could think of to implement this is with
has_and_belongs_to_many. Am I right, or is there a better way to do
this?
2006 Jul 26
8
team captain - habtm w/has_one...
the below...
class User < ActiveRecord::Base
has_and_belongs_to_many :teams
class Team < ActiveRecord::Base
has_and_belongs_to_many :users
has_one :captain, :class_name => ''User''
produces the error...
Mysql::Error: Unknown column ''users.team_id'' in ''where clause'': SELECT *
FROM users WHERE (users.team_id = 1) LIMIT 1
i
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 Jun 14
3
Prevent duplicate HABTM associations
Hi,
I am trying to restrict duplicate has_and_belongs_to_many associations.
I tried to find support for a association validation for duplicates but
couldn''t find anything.
I understand I could use :uniq=>true on the model association but this
would only prevent it from displaying duplicates, I want to stop
duplicate associations being inserted in the first place.
I have a vague
2006 Apr 01
1
using find with multiple objects in active record
Hi,
I am trying to learn to use RoR by making a simple social networking
example. Given a user id, I am trying to make a query that finds all of
the group that user belongs to but also rank the groups by one of the
groups'' parameter like group.size. Pretend group.size is a number from
1-10 and is precalculated. Can I do this is one query? Here are the
relationships I set up:
class