Displaying 19 results from an estimated 19 matches for "taggable_type".
2006 May 07
6
Challenging SQL for you...
...re tagged with *all* these tags.
The plugin uses primarily two tables: tags, to keep all the various tag
names and ids, and taggings, which actually associates the tags table
with other items in your database.
So, tags looks like:
[id][name]
and taggings looks like:
[id][tag_id][taggable_id][taggable_type]
id and tag_id above serve to join the two tables...taggable_id is the id
of a tuple in another relation in the database, and type is the name of
said relation.
What I want to do is select * taggable_id''s from taggings that have
tag_ids matching a set of ids from the tags table.
S...
2006 Apr 21
3
polymorphic,has_many through can not work?
...39;s procedure:
class Tagging < ActiveRecord::Base
belongs_to :tag
belongs_to :taggable, :polymorphic => true
belongs_to :article, :class_name => "Article",
:foreign_key => "taggable_id",
:conditions => "taggable_type = ''Article''"
belongs_to :user, :class_name => "User",
:foreign_key => "taggable_id",
:conditions => "taggable_type = ''Book''"
end
class Tag < ActiveRecord::Base...
2006 Jun 30
0
find_by_sql not quoting properly (in acts_as_taggable plugin)
...ts_as_taggable.rb is:
def find_tagged_with(list)
find_by_sql(["SELECT #{table_name}.* FROM #{table_name},
tags, taggings " +
"WHERE #{table_name}.#{primary_key} =
taggings.taggable_id " +
"AND taggings.taggable_type = ''#
{acts_as_taggable_options[:taggable_type]}'' " +
"AND taggings.tag_id = tags.id AND tags.name
IN (?)", list]
)
end
Originally, this built a string directly to pass to find_by_sql, but
I changed it thusly:
trunk/...
2006 Feb 16
1
[PATCH] acts_as_taggable plugin
...- "SELECT #{table_name}.* FROM #{table_name}, tags, taggings " +
+ "SELECT DISTINCT #{table_name}.* FROM #{table_name}, tags, taggings " +
"WHERE #{table_name}.#{primary_key} = taggings.taggable_id " +
"AND taggings.taggable_type = ''#{acts_as_taggable_options[:taggable_type]}'' " +
"AND taggings.tag_id = tags.id AND tags.name IN (#{list.collect { |name| "''#{name}''" }.join(", ")})"
)
end
+
+ def find_tagged_w...
2006 May 06
3
Extending Rails plugins?
...wing module:
==
module SingletonMethods
def find_tagged_with(list)
find_by_sql([
"SELECT #{table_name}.* FROM #{table_name}, tags, taggings " +
"WHERE #{table_name}.#{primary_key} = taggings.taggable_id " +
"AND taggings.taggable_type = ? " +
"AND taggings.tag_id = tags.id AND tags.name IN (?)",
acts_as_taggable_options[:taggable_type], list
])
end
end
==
Thanks!
B.A.
--
B.A. Baracus: I thought you weren''t crazy no more?
Murdock: Only on paper.
--
Posted...
2006 Jul 14
5
Acts_As_Taggable Plugin multiple controllers.
...s people only.
I''m guessing I need to filter it somewhere but haven''t found the place yet.
taggings db
create_table :taggings do |t|
t.column :tag_id, :integer
#id of tagged object
t.column :taggable_id, :integer
#type of object tagged
t.column :taggable_type, :string
end
thanks in advance
john
2006 Feb 09
3
acts_as_taggable Produces Bad SQL - Find Fails
...ecords with that tag.
So, I''m doing this:
@lists = List.find_tagged_with :any => @search_string, :separator => ''+''
The problem is that the SQL generated looks like this:
SELECT lists.* FROM lists, tags, taggings WHERE lists.id =
taggings.taggable_id AND taggings.taggable_type = ''List'' AND taggings.tag_id
= tags.id AND tags.name IN (''anylasvegas'', ''separator+'')
See what''s right after the IN clause? It says ''anylasvegas'' - why? BTW,
using ''lasvegas'' returns the correct resu...
2006 Aug 10
2
search acts_as_taggable for multiple tags
Hey...I''m trying to search a Model that uses acts_as_taggable for multiple tags. I''d like to pass in a search string containing a space delimited tags names (i.e. "tag1 tag2") and return the objects that have been tagged by either one of those. Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Sep 27
1
acts_as_taggable with single-table inheritance?
Does anyone have any experience making this work? I installed the
plugin and tried the following:
class SomeClass < ActiveRecord::Base
acts_as_Taggable
end
class SubClass1 < SomeClass
end
class SubClass2 < SomeClass
end
SubClass1.tag_with("tag")
and notice that taggable_type = SomeClass
when I do SubClass2.find_tagged_with("tag") a SubClass1 object is
returned.
Any help would be greatly appreciated!
.Martin
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribe...
2006 Nov 11
0
acts_as_taggable plugin - paging through tagged model
...replace old find_tagged_with - with the below..
def find_tagged_with(list, options = {})
query = "SELECT #{table_name}.* FROM #{table_name}, tags, taggings "
query << "WHERE #{table_name}.#{primary_key} = taggings.taggable_id "
query << "AND taggings.taggable_type = ? "
query << "AND taggings.tag_id = tags.id AND tags.name IN (?) "
query << "limit #{options[:limit]} " if options[:limit] != nil
query << "offset #{options[:offset]} " if options[:offset] != nil
find_by_sql([query, acts_as_tagga...
2008 Jun 13
1
Polymorphic :through associations
...his one
has me stumped.
Here is an example DB.
Tags Table:
-------------------------
id
name
Taggables Table:
--------------------------
id
tag_id
taggble_type
taggable_id
For purposes of this example say that there are 2 other tables that
can be tagged and their model name would appear in the taggable_type
field along with their id in the taggable id.
I have seen this done somewhat with the:
belongs_to :taggable, :polymorphic => true
but never with a join table or a :through to store extra info.
Can this be done this way or am I completely off track?
Thanks,
Chris
--~--~---------~--~----~----...
2006 Apr 07
0
acts_as_taggable and tag list
Hi,
I''m using the new acts_as_taggable on Rails 1.1.1. I would like to get a list of all the tags for a particular model type, in my case "Post". I got it to work with:
Tag.find(:all,:include => :taggings, :conditions => "taggable_type=''Chunk''")
But I''m wondering if there''s a more Rubyish elegant way.
thanks, scott.
----------------------------------------------------------------------------------------------------
What''s an Intel chip doing in a Mac? A whole lor more that it&...
2006 Feb 09
0
acts_as_taggable Generating Funky SQL
...ecords with that tag.
So, I''m doing this:
@lists = List.find_tagged_with :any => @search_string, :separator => ''+''
The problem is that the SQL generated looks like this:
SELECT lists.* FROM lists, tags, taggings WHERE lists.id =
taggings.taggable_id AND taggings.taggable_type = ''List'' AND taggings.tag_id
= tags.id AND tags.name IN (''anylasvegas'', ''separator+'')
See what''s right after the IN clause? It says ''anylasvegas'' - why? BTW,
using ''lasvegas'' returns the correct resu...
2011 Sep 17
0
joining and array with a table in ActiveRecord
Hey
I am pretty new to Ruby on Rails and I have no idea how to solve the
following:
I have a join query on a table like this:
def mytags
Taggable.joins("JOIN taggables as filter ON taggables.tag_id =
filter.tag_id WHERE filter.taggable_type = ''User'' AND filter.taggable_id
= 1").all
end
this works perfectly fine.
then I want to join the result on another table, where
OtherTable.joins(@mytags) works also fine BUT I want to
join on two other colums and NOT on the ids....
Can anyone tell me how to do this?
thx...
2009 Sep 09
4
Tagging recommendation - acts_as_taggable_on_steroids best?
hey all
What''s the most popular tagging plugin/gem these days? Is it
acts_as_taggable_on_steroids? Or is something else better?
I''d like to basically replicate flickr''s tagging as much as possible, eg
allowing multi-word tags to be denoted by quotes or seperated by commas.
thanks
max
--
Posted via http://www.ruby-forum.com/.
2006 Nov 04
2
strange errors in dev.log and webserver log
...ards WHERE (cards.id = ''5'') LIMIT 1
Rendering within layouts/admin
Rendering cards/edit
Card Columns (0.004928) SHOW FIELDS FROM cards
Tag Load (0.001597) SELECT tags.* FROM tags INNER JOIN taggings ON
tags.id = taggings.tag_id WHERE (taggings.taggable_id = 5 AND
taggings.taggable_type = ''Card'')
Tag Load (0.002008) SELECT * FROM tags
Tag Columns (0.003178) SHOW FIELDS FROM tags
Rendered cards/_form (0.02718)
Completed in 0.05205 (19 reqs/sec) | Rendering: 0.02855 (54%) | DB:
0.01755 (33%) | 200 OK [http://dev/cards/edit/5]
Processing IndexController#no...
2009 Feb 27
2
Getting unique entries from models?
I''m using acts_as_taggable_on and I want to get a list of unique
taggings. How can I do this? In a more general sense, say that I have
a Product model with attributes name and price. I have these:
id: 1
Name: Juice
Price: 5
id: 2
Name: Juice
Price: 5
So when I do a Product.find(:all) I''ll get both, but I only want one.
How can I do this so that no matter now many
2006 Dec 20
4
undefined method `fullname' for #<User:0x357e380>, BUT works on first view?
...news
News Load (0.000302) SELECT * FROM news WHERE (news.id = 13)
Rendering within layouts/application
Rendering news/show
Tagging Columns (0.000286) SHOW FIELDS FROM taggings
Tag Load (0.000444) SELECT tags.* FROM tags INNER JOIN taggings ON
tags.id = taggings.tag_id WHERE ((taggings.taggable_type = ''News'') AND
(taggings.taggable_id = 13))
Tag Columns (0.000187) SHOW FIELDS FROM tags
Rendered /news/_item (0.00561)
Comment Load (0.000301) SELECT * FROM comments WHERE
(comments.commentable_id = 13 AND comments.commentable_type = ''News'')
Comment Col...
2006 Mar 31
14
[newbi] Create a Model
Hello All,
Yesterday i put RoR with Locomotive. I am very happy :p.
So I follow this tuto
(http://developer.apple.com/tools/rubyonrails.html). I used Sqlite.
my database.yml
# MySQL (default setup). Versions 4.1 and 5.0 are recommended.
#
# Get the fast C bindings:
# gem install mysql
# (on OS X: gem install mysql -- --include=/usr/local/lib)
# And be sure to use new-style password