Displaying 10 results from an estimated 10 matches for "thing_ids".
Did you mean:
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
2006 Feb 16
1
HABTM -VS- belongs_to/has_many, for self-referential joins
Ok, David says on page 241 that sometimes a many-to-many relation with
attributes are better implemented as an actual model instead of using HABTM.
Well, I''ve got that situation and I can''t figure it out.
All of the examples in the book have HABTM examples between 2 different
tables, but I want to have a HABTM relation on 1 table with itself. (e.g.,
if I have a table Things,
2006 Mar 29
4
:through alternate
I''d like to use :through to create a web of associations like:
class Thing < ActiveRecord::Base
has_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 =>
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
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
Let''s start with an example:
---
class Comment < ActiveRecord::Base
end
# dummy (to invent a "table namespace")
class Review < ActiveRecord::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 =>
2005 Dec 20
3
Single controller to browse things in categories
First off, hi, I''m [obviously] new :O)
Please excuse my question as I''m sure it''s been answered, but I can''t
find it anywhere.
I have a table of categories:
id name
1 Foo
2 Bar
I have things which belong_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
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