Displaying 20 results from an estimated 5000 matches similar to: "created_on in HABTM table getting parent dates"
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
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 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 Apr 05
5
Updating attributes in HABTM association
Hi,
I am trying to find a way tp update attributes in a habtm association. I
am trying to use the code from ticket #2462, but as my
association_class_primary_key_name seems to be empty the generated sql
code is corrupt. I hope thats not a problem of my model that this
variable is empty.
What would you recommend to update those attributes (rails 1.1)
THANKS!!!
--
Posted via
2006 Jun 01
3
Newbie: HABTM problems
I''m new to RoR and trying to make a HABTM relationship work. I have
no problems with displaying the fields (after I pumped the data into
MySQL manually outside of RoR), but when I try to edit a record, it
=does= save the changes in the primary record, but =not= the join
table. When I look in the development log, I see the update to the
main table, but nothing about the join
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
2006 May 24
1
AR many-many join tables - can they have created_on, updated_on ?
Hello all,
I''m creating a many-many join table between ''homes'' and ''users''. Can it
contain created_on? will AR update created_on, updated_on on this table?
CREATE homes_users (
home_id int not null,
user_id int not null,
created_on datetime null,
updated_on datetime null
)
Thanks for your advice!
--
------------------------------
Apple MacBook.
2006 Mar 04
10
Help setting up relationships needed
This is a bit of a long question, but to those of you with some
experience, it should be fairly simple I think.
I have a notes page that should list all notes the user has entered for
all books chronologically like this.
Book One: This is the note.
Book Four: This is the note.
Book One: A different note, entered later.
Right now my models are:
User
has_many :books
Book
has_many
2006 Apr 30
2
HABTM: Find sorted by number of associations
Hi,
I''ve been googling and searching the forums for some time
but can''t seem to find exactly what I''m looking for.
Suppose User HABTM Products (for example a favorites list). I would like to
construct a single query for finding Products ordered by the number of
Users that have flagged them as favorites.
Although I can construct the query using SQL a with a
2006 Jun 05
5
adding habtm through migrations
Hello,
I''m stuck, I''ve got a model Product and would like to add a new model
called Category. Furthermore, I want to set up a many2many
relationship between the mentioned models. the problem is that I do
not know how to set the primary key in the categories_products table.
this is what I''ve got in my migration file:
create_table :categories do |t|
t.column :name,
2006 Jun 16
3
Does HABTM support non "id" FKs?
Quick question. Say I have a geographical database with counties and zip
codes where counties have and belong to many zip codes.
zip_codes (id, zip_code)
counties (id, name)
When I create the association table, the Rails way says to do the
following: counties_zip_codes (county_id, zip_code_id).
However, given that zip_codes.zip_code is itself a candidate key, I
would much prefer to do the
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 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 Jul 12
1
odd habtm behavior? or is it me?
Hello List,
I''m a bit spent on this problem, and my code might be whack. I seem to be
encountering a problem where the primary key on a join table is not being
resolved correctly. I will elaborate after some code bits. I am creating
the join table using migrations, and relevant model code is this:
class Post < ActiveRecord::Base
has_and_belongs_to_many :records
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 Aug 09
3
HABTM and getting to arrays from either direction
I didn''t find exactly an answer on this one, so I''d like to get a
clarification from folks who live & breathe HABTM.
class foo
has_and_belongs_to_many :bars
end
class bar
has_and_belongs_to_many :foos
end
(and yes, I have a bars_foos table in my db)
def test_habtm
bar = Bar.new
foo = Foo.new
foo.bars<<bar
assert !foo.bars.empty?
assert
2006 Aug 07
4
multiple habtm joins on the same two tables
i have a taskmanager type of project that i am working on, where i need
to separate joins on the same two tables. i need one join for users that
are assigned to the task, and another join for who has read the task, so
they can tell which ones are new.
any suggestions on the best way to accomplish this?
thanks
--
Posted via http://www.ruby-forum.com/.
2006 Jun 11
2
HABTM Duplicates?
Hello all,
I''m working on a small Rails site for a game I play that will
be used to add new characters. Part of this addition process is choosing what
skills the character will have. For this, in MySQL, I have a characters table
and a skills table, as well as a characters_skills table that is used as the
join table in the habtm relationship between the two. I am presenting the
skills in
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 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