While I''m digging through the docs to figure out how to do this, I figured I''d post to the list and see if anyone else has done something similar. I have an application that has a HABTM relationship with itself (just users in the system). The model looks like this: class User < ActiveRecord::Base has_and_belongs_to_many :friends, :class_name => "User", :join_table => "users_friends", :association_foreign_key => "friend_id" end and associated schema: CREATE TABLE users_friends ( user_id INT default 0, friend_id default 0 ); In the user edit action, I''d like to display the list of friends via a component, and paginate the list. That is, given a user, I want to select all users from the join table whose friend_id matches the user_id of the current user. Does anyone know how to set up the paginator for something like this? Thanks, Joe
Never mind. It was pretty easy - sql = "users.id = users_friends.friend_id " sql << "AND users_friends.user_id = ?" @user_pages, @users = paginate :users, { :conditions => [ sql, @session[''user''].id ], :join => ", users_friends", :per_page => 10 } On Aug 11, 2005, at 11:04 AM, Joseph Hosteny wrote:> While I''m digging through the docs to figure out how to do this, I > figured I''d post to the list and see if anyone else has done > something similar. > > I have an application that has a HABTM relationship with itself > (just users in the system). The model looks like this: > > class User < ActiveRecord::Base > has_and_belongs_to_many :friends, :class_name => > "User", :join_table => "users_friends", :association_foreign_key => > "friend_id" > end > > and associated schema: > > CREATE TABLE users_friends ( > user_id INT default 0, > friend_id default 0 > ); > > In the user edit action, I''d like to display the list of friends > via a component, and paginate the list. That is, given a user, I > want to select all users from the join table whose friend_id > matches the user_id of the current user. > > Does anyone know how to set up the paginator for something like this? > > Thanks, > Joe > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Anyone shed any light on this? Resources, links, docs? TIA! John B
What type of functionality are you looking for? Applets are a bit of an overkill for most web-based needs (IMO). Can you give an example of the type of functionality an applet type distribution would better provide you rather than other RIA options (ajax/js/dhtml)? -dave On 8/11/05, speechexpert <speechexpert-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote:> Anyone shed any light on this? > Resources, links, docs? > TIA! > John B > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- ~~~~~~~~~~~~~~~~~~~ D''Andrew Thompson http://dathompson.blogspot.com
speechexpert wrote:> Anyone shed any light on this?What is "this"? Aren''t applets small applications, written in Java, that require a browser sandbox environment for execution? Perhaps you could shed some light on what you are trying to do. James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys