Page 1 of 1
[11:13:54] marcules: Can I add a method to my model, and then use this method like any other property, like: def smallest_calculating_price end --> :smallest_calculating_price
[11:15:34] marcules: I have a model with "price", "price on sale", "price range (lower)" and "price range (higher)" --- I'd like to have a definitive answer (for sorting purposes) which is the currently smallest price in this model; like I want to use it in sunspot also @universa1
[11:35:27] marcules: universa1: I just figured it out, I could define a new field in searchable, and append a do block, which calls my method
[20:04:34] marcules: hmmm... if I wanted to return hits with sunspot/solr which are not matching, how would I best go about it? I'm trying to first match "good matches", and then "everything else" from that category -- should I just first search with sunspot, fetch the id's and concatenate the missing items, in default order?
[20:07:11] marcules: I'm pretty new to rails - only started working with it beginning of last week... I'll look at it, but probably won't know what's wrong
[10:31:01] marcules: Which gem would you guys use for a fulltext search on ActiveRecord models? sunspot?
[17:14:14] marcules: If I destroy an ActiveRecord instance, which is related to another instance, over a join table; is the entry in the join-table also being removed?
[17:19:49] marcules: Sharcho: I have a many-to-many relation; so when I use dependent: :destroy on has_many :item_categories_items it will not propagate to :item_categories unless I have a second dependant-declaration in the join-model, right?
[17:21:12] marcules: No I mean - I don't want it to propagate; so I assume I would be safe with only one; I'll test it now :D
[17:28:49] marcules: hmm odd.. I think rails appends a "." where there shouldn't be one while executing the delete statement
[17:39:38] marcules: Did I mess up with my many-to-many relation? I get an exception when deleting Items (the SQL statement is corrupt, it's missing the column name (item_id) --> https://gist.github.com/marcules/99c008a7d981cfdbfada
[17:48:03] marcules: rhizome: https://gist.github.com/marcules/99c008a7d981cfdbfada#file-deletecode-rb-L41
[17:51:13] marcules: rhizome: previously I also had this in line 41: ItemCategoriesItem.destroy_all(item_id: item.id)
[17:53:40] marcules: rhizome: still getting: SQLite3::SQLException: no such column: item_categories_items.: DELETE FROM "item_categories_items" WHERE "item_categories_items"."" = ?
[17:58:21] marcules: hmm rhizome I'll ignore it for now and come back to it if I have the time; thank you anyways :)
[16:17:23] marcules: I have kind of a... database... or... rather "logic" related problem; I'm trying to save items, which belong to item_categories, into item_categories.items; BUT I also want only one request for all available subcategory-items; so I'm populating all parents recursively while saving a subcategory and adding the new items to the parents this way. Only problem now is, that I have to also remove old items, which are no longer neede
[16:17:38] marcules: diff_items = (old_items - new_items) isn't working anymore; illustration: http://i.imgur.com/EiimeGr.jpg
[16:24:29] marcules: mikecmpbll: basically I'm trying to get all items, from my category and all its subcategories; but I wanted to do it with only one db lookup, so I'm trying to find a way of populating the parent categories with the items from the subcategories; the problem is - the parent categories themselves can have items, which are unrelated to the child categories, so my check for "old items" fails at that point
[16:26:01] marcules: mikecmpbll: I'm getting the item descriptions from another system, and have to deduce which items are no longer valid from the missing items of that service
[16:27:02] marcules: So if a subcategory has [a, b, c] and is updated to [a, c, d] - b should be purged from the database
[16:28:39] marcules: Yes, because if subcategory a contains 100 items, and subcategory b contains 100 items, category A contains 200 items -- but if you try to add 100 items to category A it does not however contain 300 items but is reduced back to 100 items, because it cannot check if the items are valid or not because the foreign system only delivers items for that category and not its subcategories
[16:32:06] marcules: invalid is the difference from the current model: invalid_items = (old_items - new_items) where old_items and new_items are arrays of old and new items
[16:33:45] marcules: yeah no :D - the problem only exists in the upper layers of categories; if you look at the bottom most subcategory, your approach works
[16:34:13] marcules: but a parent category can have items of its own, in conjunction to its child category items
[16:34:45] marcules: if the parent has all items from all subcategories, and recieves an updated list of items itself, it would remove the subcategory items
[16:36:25] marcules: maybe it's just a retarded idea to propagate the item-creation upstream to the parent categories, and I should just do more db lookups on retrieval
[16:38:33] marcules: mikecmpbll: how'd you do that? The items are not restricted to a category, they can be in multiple categories
[16:54:40] marcules: mikecmpbll: I'm doing it whenever a category is being edited; and I had planned on doing it in a scheduler; but yes it's happening all in the same procedure
[16:57:02] marcules: I think the problem is rather, that the API is not designed for what I have to do
[23:21:47] marcules: hmm.. how would I know the difference between %20 and + while accessing params?
[23:37:58] marcules: ?tags=red%20hair+short%20hair <<< this would generate "red hair short hair" in the params chridal