Displaying 4 results from an estimated 4 matches for "problems_tag".
Did you mean:
problems_tags
2006 Jun 09
2
Creating An Extra Association Between Two Tables
...name => tag)
But if I have the tag already in the DB and just want to link it to
another problem it does not really like me. I do it like this:
self.tags << Tag.find_by_name(tag)
I get the following error:
Mysql::Error: Duplicate entry ''20'' for key 1: INSERT INTO
problems_tags (`tag_id`, `problem_id`, `id`) VALUES (20, 33, 20)
The problem is basically that it is trying to create a row in
problem_tags with an ''id'' that already exists. How come it is trying
to do that? How can I prevent it from doing that?
Thanks for your help guys and gals!
Jo...
2006 May 23
2
HABTM for Dummies Question
...uot;, :datetime
t.column "updated_at", :datetime
end
create_table "tags" do |t|
t.column "name", :string
t.column "created_at", :datetime
t.column "updated_at", :datetime
end
create_table "problems_tags" do |t|
t.column "problem_id", :integer
t.column "tag_id", :integer
end
====
Now, from the console I do the following:
====
problem = Problem.find(1)
problem.tags.create :name => "test this tag"
====
The problem is that a row is added...
2006 Jun 10
3
Weird Problem With Active Record
...ms.each do |problem| %>
...
<%= problem.created_at %>
...
<% end %>
Now, how come the created_at is being taken from the HABTM
relationship instead of the problem table itself? This does not make
sense to me. How would I get created_at from Problem table instead
of problems_tag table?
Thanks for your help?
John Kopanas
http://www.kopanas.com
============================================================
http://www.soen.info - Index of online software engineering knowledge
http://www.cusec.net - Canadian University Software Engineering
Conference
http://www.soenlive.c...
2006 Jun 10
0
Ordering Based on created_at in HABTM relationship
I have the following line in my controller:
@tag = Tag.find_by_name @params[:id]
Now, how do I order the rows based on the HABTM relationship
problems_tags i.e. problems_tags.created_at DESC
Thanks :-)
John Kopanas
http://www.kopanas.com
============================================================
http://www.soen.info - Index of online software engineering knowledge
http://www.cusec.net - Canadian University Software Engineering
Conference
http...