search for: tag_id

Displaying 20 results from an estimated 60 matches for "tag_id".

2006 May 07
6
Challenging SQL for you...
...ly those items that are 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...
2006 Aug 29
2
Excluding values from search term
I''m trying to do a search that would exclude a value from it and return whatever results aren''t matched from the term, but it''s not working very well. None of these are working, they all return the results including the ones with tag_id = 701 tag_id:(NOT 701) tag_id:(! 701) tag_id:(- 701) But if I go the other way around it works (which I don''t want since I have thousands of tags): tag_id:(1 OR 2, etc...) Any thoughts? -- Posted via http://www.ruby-forum.com/.
2006 Mar 31
7
problem with habtm conditions in pagination
...b.net/paste/results/ kXQSHZ83.html But I''ll paste it here, too. The main problem is in the customers/list action. The problem is with this line: @customer_pages, @customers = paginate :customers, {:per_page => 10, :include => ''tags'', :conditions=>''tag_id = 3''} It''s generating the exception below. Any help would be INCREDIBLY appreciated. Please b/cc me in on any replies. Kind Regards, Julian. #The problem is in the customer-list action. #... it yields the error below the source code that follows: # source code follows: cla...
2006 Jul 31
1
How to get result of following SQL Query in Ruby?
Hi, I have 2 tables as follows:- _________________ ________________ ____________ taggings | |stores | | tags | -----------------| |---------------| |------------| --tag_id | |--store_id | |tag_id | --store_id | |--store_name | |tag_name | --user_id | |---------------| |------------| -----------------| Now I want to execute followin sql query on above tables:- "select name from tags where tag_id in (select tag_id from tag...
2010 Feb 14
2
has_many :through eager loading only loading one record
...problem is that Active Record is only eager-loading the first of many records. Here are the models (note set_table_name for a legacy schema): class Tag < ActiveRecord::Base set_table_name ''tag'' end class DishTag < Tag has_many :dish_taggings, :foreign_key => ''tag_id'' has_many :dishes, :through => :dish_taggings end class DishTagging < ActiveRecord::Base set_table_name ''dish_tag'' belongs_to :dish belongs_to :dish_tag, :foreign_key => ''tag_id'' end class Dish < ActiveRecord::Base set_table_name '...
2006 Apr 15
6
Two forms for two models - one page
I''ve got two forms for two different models on the same page. What I want is for one of the forms to return you to the same "new" page and not clear the data in the other form. I was hoping it would be as simple as render :action => ''new'' but no such luck. Any thoughts? Thanks, Adam -- Posted via http://www.ruby-forum.com/.
2013 Feb 28
1
Make `ActionView::Helpers::InstanceTag#tag_id`, `ActionView::Helpers::InstanceTag#tag_id_with_index(index)` public?
As I asked in StackOverflow<http://stackoverflow.com/questions/15127658/hoe-to-get-tag-id-from-a-record-in-form-for/15129741> I think it would be helpful since we can dynamically create javascript code to control each input tag in form helper, what do you think? Or there has already been a solution? -- You received this message because you are subscribed to the Google Groups "Ruby
2006 Jun 22
2
id column for join table... kosher?
...out join tables implicitly from the associations, but if I do a rake migrate the join tables won''t be built. I''ve been creating them using SQL/by hand. 2. Is there anything wrong with having an ''id'' column on my join table? Rails expects: bookmark_id & tag_id ...but what if I want to reference individual joins? Can I do: bookmark_id & tag_id & id Does this mess anything up? The Agile book says don''t do it, articles on the web say it''s OK. Who to believe? Thanks for any/all advice! -Jason
2010 Jan 15
1
Chaining queries in ActiveRecord
Hi all, Stuck at this problem for several days. Tried to use named_scope, scope_out, and plugin such as searchlogic, but no result. The problem is as follows: I have a pic table and tag table, and a join table called pic_tag (with only pic_id and tag_id) so that I can associate N pics to M tags. This is the tutorial way to set up a many- to-many association. I''m trying to implement a simple search function, so that I can search for a picture with several given tags. Now say I want to search for pics that are tagged with "dog" a...
2006 Aug 09
1
help:sql search for NULL
...ode but it doesn''t return anything. I wonder what I am doing wrong. Any help is greately appreciated. def self.match_for_assignment(assignment) self.find(:all, :conditions => [''matches.member_id IN (?, NULL) AND matches.study_id IN (?, NULL) AND matches.tag_id IN (?, NULL)'', assignment.member.id, assignment.study.id, assignment.tag.id]) end -- Posted via http://www.ruby-forum.com/.
2006 Apr 26
3
acts_as_taggable gem: deleting tags
I have the following quick-and-dirty hack in my model: def after_destroy # search for orphaned tags and delete them orphans = Resource.tags_count :count => ''= 0'' orphans.keys.each {|tag| Tags.find_by_name(''tag'').destroy} end It''s nice from a readable code perspective, but it seems inefficient - is there some way to do this with only one
2006 Jun 30
0
find_by_sql not quoting properly (in acts_as_taggable plugin)
...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/vendor/plugins/acts_as_taggable/lib/acts_as_taggable.rb r13 r127 25 25 module SingletonMethods 26 26 def find_tagged_wi...
2006 Jan 23
2
del.icio.us-like output
...f78b8e4eb0851ae24a1994f105&jump=no> There are several things going on there that make it hard/impossible/inefficient to do it one query. I''m soliciting tips on how to do this most efficiently. For me, the data is in 4 tables. Bookmarks (id, bookmark) Tags (id, tag) Tags_Bookmarks (tag_id, bookmark_id, user_id) Users (id, username) I have a query that can get me most of the info I need, but not necessarily in the format I need it in. sql = "SELECT jt.tag_id, b.id bid, t.tag, b.bookmark, jt.created_on FROM tags_bookmarks jt LEFT JOIN tags t ON jt....
2005 Sep 06
6
strange behavior of acts_as_taggable
...ry and I got: >> s.tag "warp" ActiveRecord::StatementInvalid: ERROR: inserción o actualización en la tabla «tags_stories» viola la llave foránea «tags_stories_story_id_fkey» DETAIL: La llave (story_id)=(8) no está presente en la tabla «stories». : INSERT INTO tags_stories ("tag_id", "story_id") VALUES (''3'', ''8'') from ./script/../config/../vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:462:in `log'' from ./script/../config/../vendor/rails/activerecord/lib/active_...
2006 Dec 11
2
join and sort on 'best match'
...: news, nature Item 3 : news, nature, greenpeace, whale Item 1 and Item 3 are the best match. So far, the SQL I came up wiht looks like: SELECT id, COUNT(items_tags.item_id) AS quantity FROM items JOIN items_tags ON items_tags.item_id = items.id WHERE id in (select item_id from items_tags where tag_id in (select tag_id from items_tags where item_id=?)) GROUP BY items_tags.item_id,id ORDER BY quantity DESC note: the ''?'' in the query represents the dynamic part: I have 1 item and I want to look up matching items. To me, this query means the following: - get all items that have...
2006 Mar 13
5
Displaying related entries by tags - HELP!
...uot;, :category => tag.name.to_s }.join(", ") %> <p><%= post.entry %></p> <% end %> #layout <% for related in @contents_related %> <li><%= related.title %><br /></li> <% end %> #controller (how do I pass the tag_id and the content_id?) @contents_related = Content.show_related_entries(?,?) #model def self.show_related_entries(t_id, c_id) find_by_sql("select c.title from contents c inner join contents_tags ct on c.id = ct.content_id where ct.tag_id = #{t_id} and c.id != #{c_id}") end The fun...
2005 May 23
1
has_and_belongs_to_many dual insert error ?
...r edits the list, and separates the words using a comma. Then, my controller splits everything back, and asks the Picture domain object to update it''s tags. The implementation is at the bottom, but the end result is that I get two rows like this: INSERT INTO pictures_tags(picture_id, tag_id) VALUES (13, 21); INSERT INTO pictures_tags(picture_id, tag_id) VALUES (13, 21); If I add a unique index to pictures_tags, MySQL rejects the second insert, as it should. The only way I found to prevent that problem is to save my picture first, and then to update the tags. Is that behavior expe...
2006 Feb 09
3
acts_as_taggable Produces Bad SQL - Find Fails
...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 results. I used the :any symbol in the finder per...
2006 Jun 09
2
Creating An Extra Association Between Two Tables
...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! John Kopanas...
2006 Apr 04
5
How to implement tag clouds using plugin?
...an corresponding implementation for acts_as_taggable plugin : def tags_count(options) sql = "SELECT tags.id AS id, tags.name AS name, COUNT(*) AS count FROM tags, taggings, #{table_name} " sql << "WHERE taggings.taggable_id = #{table_name}.#{primary_key} AND taggings.tag_id = tags.id " sql << "AND #{sanitize_sql(options[:conditions])} " if options[:conditions] sql << "GROUP BY tags.name " sql << "HAVING count #{options[:count]} " if options[:count] sql << "ORDER BY #{options[:order]} " i...