search for: thing_id

Displaying 10 results from an estimated 10 matches for "thing_id".

2005 Jul 07
2
0.13 ajax sortable lists and acts_as_list
...like they''re designed to mesh well. The ajax sortable lists post a complete ordered list of ids back to the server after every change, but acts_as_list is designed to deal with diff-like changes, rather than reordering the whole list from scratch. My quick and dirty solution is to @thing_ids = params[:things] @thing_ids.each do |thing_id| Thing.find(thing_id).move_to_bottom end But that''s rather inefficient, and quite slow when you''re ordering large lists. Any better ideas? Tyler
2005 Jul 12
2
save order from drag and drop
only just found the script.aculo.us site. brilliant. much respect. wondered if anyone can point me in the right direction on this drag and drop list re-ordering type thing, i''ve read through what I can but to be honest it''s gone right over my head! How do I get the new order that has been established via dragging list elements around and store them in a database. I figured an
2006 Apr 18
6
Linking one model to another
I have a User model and a Thing model. I want to link users with things, so I have a migration that creates a permissions table with user_id and thing_id. The migration works fine and gives me three columns, I assume I need the permission''s ID so that I can delete it in future. Three questions come to mind though, which I have given thought but got nowhere. 1) Does the permissions table need the ID column? 2) Is there any way in the...
2006 Feb 16
1
HABTM -VS- belongs_to/has_many, for self-referential joins
...but I want to have a HABTM relation on 1 table with itself. (e.g., if I have a table Things, then I would like one "Thing" to "helpout" another Thing) ---------------------- Table 1: "Thing" Column: Name ---------------------- Table2: "Helps" Column: thing_id (e.g. "this thing.") Column: helps_id (. "helps that thing") ---------------------- It seems like I might want to use a HABTM, but I can''t figure out the settings. OR (and I think this is what I actually need / want to do), I need a separate model to represent H...
2006 Mar 29
4
:through alternate
...s_many :child_things, :through => :thing_thing has_many :parent_things, :through => :thing_thing, :some_other_option? end class ThingThing < ActiveRecord::Base belongs_to :thing belongs_to :child_thing, :class_name => ''Thing'', :foreign_key => ''child_thing_id'' end The child_things works. The parent_things does not, or at least, I cannot figure out the sytnax. I would like it to issue an sql like: SELECT things.* FROM things INNER JOIN thing_things ON things.id = thing_things.thing_id WHERE (thing_things.child_thing_id = 6201) Is there a wa...
2006 Aug 12
1
has and belongs to many different?
Is there such a thing? I am thinking of an application that has something like this: 1. person has many things - there is a ''persons'' table 2. the things he has are stored in a table that is something like this person_id, thing_table_name, thing_id For example, it may map to person1, books, 23 #Person 1 owns book 23 person1, books, 25 #Person 1 owns book 25 person1, chair, 23 #Person 1 owns chair 23 person1, books, 30 person2, books, 19 person2, books, 31 #Person 2 owns book 31 ... and so on.. 3. A number of tables fo...
2006 Feb 11
1
Retaining multiple select values from action to action?
Suppose I have a multiple select form on an initial page called things[], and two target actions. The initial page submits to target action 1, and target view 1 submits to target action 2. When I submit the form on the initial page, I can access that set of values in target action 1 and turn it into an array of objects by doing something like this (assuming that the option values are object ids,
2008 Oct 16
5
2 Models: Same name, different namespace => Problems
...cord::Base end # ... dummy # is "review_comments" in the database class Review::Comment < ActiveRecord::Base belongs_to :thing end class Review::Thing < ActiveRecord::Base has_many :comments, :class_name => ''::Review::Comment'', :foreign_key => ''thing_id'' end --- Then we use the models in a view: (I know it''s not clean to use the models directly in the view, but it is simply an example --- <% Comment.find(:all).each do |c| %> <%= c.created_at %> <% end %> <hr/> <% Review::Thing.find(:first).comments....
2005 Dec 20
3
Single controller to browse things in categories
...elong_to categories: id category_id subject date 1 1 my subject 07/09/2004 and Further classifications which belong_to categories: id category_id name 1 1 More Foo 2 1 Most Foo 3 2 Some Bar and subcategories which belong_to categories, classifications, and things id category_id classification_id thing_id 1 1 1 some item 2 1 2 another item I want my index to contain links to those categories: Foo Bar By clicking on Foo, I''d like it to display things belonging to Foo, and expand to show classifications Foo - More Foo (Foo Stuff) - Most Foo Bar It seems like I should be able...
2006 Apr 10
5
ActiveRecord: Behavior not doumented
Hello everbody, doing a #find(:first,an_id) with Rails 1.1.0 I expected that find returns the record which id mathches the given parameter an_id or nil if it couldn''t be found. This behaviour is documented on api.rubyonrails.org. But the find returns the first available object and not nil if an_id is not in the db. Is the doc on rubyonrails.org out of sync? Greetings, -- Daniel