| Issue 89: | it is expected to show the products tagged with this tag. but list all the products . (the newest version :substruct_rel_1-0-a3.tar.gz) | |
| 3 people starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. go to http://localhost:3000/admin/tags/list create some tags
2. http://localhost:3000/admin/products/new create some products, each product has only
one different tag.
3. go to public site, I find that for each tag, it will list all the products. it is a big error.
What is the expected output? What do you see instead?
for each tag, it is expected to show the products tagged with this tag. but list all the products .
What version of the product are you using? On what operating system?
the newest version:substruct_rel_1-0-a3.tar.gz, in my macbook, leopord 10.5, mysql 5.0,
Please provide any additional information below.
at last, I find this code cause this problem
in the product.rb , find_by_tags method:
sql = "SELECT * "
sql << "FROM items "
sql << "JOIN products_tags on items.id = products_tags.product_id "
sql << "WHERE products_tags.tag_id IN (#{tag_ids.join(",")}) "
sql << "AND #{CONDITIONS_AVAILABLE}" if find_available==true
sql << "GROUP BY items.id HAVING COUNT(*)=#{tag_ids.length} "
sql << "ORDER BY #{order_by};"
find_by_sql(sql)
if you delete :
sql << "AND #{CONDITIONS_AVAILABLE}" if find_available==true
sql << "GROUP BY items.id HAVING COUNT(*)=#{tag_ids.length} "
sql << "ORDER BY #{order_by};"
it works ok,
but mysql knowleage is not very good, and because there is some problem with the subnav_tags(if you tag the product with a tag and this tag' s child, and if click the child tag, list
two product, and they are the same)
so , I fix like this with my poor rails knowleage:
if tag_ids.size == 1
child_tags = Tag.find(tag_ids[0]).children.collect {|x| x.id}
tag_ids = tag_ids + child_tags
elsif tag_ids.size == 2
tag_ids.shift
end
sql = "SELECT DISTINCT * FROM items as li inner join products_tags as pt on li.id =
pt.product_id WHERE pt.tag_id IN (#{tag_ids.join(",")})"
find_by_sql(sql)
Jun 1, 2008
#1
edmundo...@gmail.com
Jun 5, 2008
Yes, I associate products with child tags without marking its top level tags too. and I am using chinese language. pls see if there is some language supporting problem
Jun 6, 2008
I cannot reproduce it in any way. But I don't have a Mac and don't use my OS in chinese. I yet don't know how did you created and associated your products and tags (simply saying that you did in another way is not enough), normally is more usefull pick up a clean system and describe a scenario with more details. In any situation it works? You can take a look at the MySQL products_tags table and see if the relations are right. The system have automate tests that test relations between products and tags, you can try it: $ ruby ./vendor/plugins/substruct/test/functional/admin/products_controller_test.rb It shoud show something like that. Loaded suite ./vendor/plugins/substruct/test/functional/admin/products_controller_test Started ................... Finished in 7.082522 seconds. 19 tests, 139 assertions, 0 failures, 0 errors
Jun 9, 2008
I'm getting this same error. It started when I switched from using mysql 4 to mysql5. The reason I switched is that I was getting a large number of "Mysql::Error: Lost connection to MySQL server during query" errors.
Jun 9, 2008
So apparently this error happens if you are navigating to a tag that does not exist.
Jun 9, 2008
Im using MySQL 5 in Ubuntu (by months) and don't have that problem. edmundo@toshibau305:~$ dpkg -l | grep mysql-server- ii mysql-server-5.0 5.0.45-1ubuntu3.3 MySQL database server binaries Can you explain how a tag that does not exist can have a link that can be clicked in the menu and make all products appear? I still cannot reproduce it.
Jun 9, 2008
The MySQL version turned out to have nothing to do with this problem. (The lost connection problem had to do with the bindings and was resolved by running apt-get install libmysql-ruby1.8) To answer your question: A tag that does not exist does not have a link that can be clicked. After I switched from MySQL 4 to 5 I created a new db. Then ran db:bootstrap and migrate. Then went back to the browser and hit reload. It happened to be on 'store/show_by_tags/tagname' where tag name no longer exists. So, if you want to reproduce this error, navigate to store/show_by_tags/sometagnamethatdoesnotexist. Unless of course you've caught this exception and rerouted.
Jun 9, 2008
No, that's ok. Thats the point, its a problem with the store controller not handling a non existent tag when using the show_by_tags action. It is a problem, but dont have anything to do with this issue. For me it raises an ActiveRecord::StatementInvalid exception. Fixed in issue 96 . The current one, I cannot reproduce.
Jun 10, 2008
Thanks for the info and the patch. Would you like me to delete my comments above as they do not apply to this issue?
Jun 10, 2008
Im not the developer of the project. But I don't think so. When deleted things changes from wrong to nonsense. If not reproductible this issue will be marked as invlid and closed in the end anyway.
Jun 15, 2008
Good discussion, glad this resolved. Thanks Edmundo again for lending a hand.
Status:
Invalid
|