From steve at wasabidesigns.co.uk Thu Mar 1 16:41:36 2012 From: steve at wasabidesigns.co.uk (Steve Bell) Date: Thu, 1 Mar 2012 16:41:36 +0000 Subject: [activeldap-discuss] how to change default mapping to ldap ou Message-ID: <8C7B6D50-8F92-4882-ABBE-0462220A24D7@wasabidesigns.co.uk> Hi All, I have active LDAP up and running in one system, but am having problems with implementing it in another system that already has a user and groups models in place. I've created two models, ldap_group and ldap_user but am having problems getting ldap to form the correct path to the entries. The structure that I have in LDAP is: ou=customers, ou=users, dc=test, dc=local (this is where the users are stored) ou=groups, ou=users, dc=test, dc=local (this is where the groups are created) The models that I have created are: class PortalUser < ActiveLdap::Base ldap_mapping :dn_attribute => 'uid',:prefix => "ou=customers", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixAccount', 'inetOrgPerson'] belongs_to :portal_group, :class_name => 'PortalGroup', :many => 'memberUid' end class PortalGroup < ActiveLdap::Base ldap_mapping :dn_attribute => 'cn',:prefix => "ou=groups", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixGroup'] has_many :portal_users, :class_name => "PortalUser", :wrap => 'memberUid', :primary_key => 'uid' end and my ldap.yaml development: host: 127.0.0.1 port: 1389 base: "ou=users, dc=test, dc=local" bind_dn: "cn=Directory Manager" password: supersecret If i try to create a user using u = PortalUser.new('test') and then look at u.base it's trying to create the user in ou=PortalUsers,ou=users,dc=test,dc=local when I want it in ou=customers, ou=users,dc=test,dc=local Unfortunately there's already models for customers and groups, so I can't just use those models. Any ideas or suggestions would be greatly appreciated. -Steve From steve at wasabidesigns.co.uk Thu Mar 1 16:41:23 2012 From: steve at wasabidesigns.co.uk (Steve Bell) Date: Thu, 1 Mar 2012 16:41:23 +0000 Subject: [activeldap-discuss] how to change default mapping to ldap ou Message-ID: Hi All, I have active LDAP up and running in one system, but am having problems with implementing it in another system that already has a user and groups models in place. I've created two models, ldap_group and ldap_user but am having problems getting ldap to form the correct path to the entries. The structure that I have in LDAP is: ou=customers, ou=users, dc=test, dc=local (this is where the users are stored) ou=groups, ou=users, dc=test, dc=local (this is where the groups are created) The models that I have created are: class PortalUser < ActiveLdap::Base ldap_mapping :dn_attribute => 'uid',:prefix => "ou=customers", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixAccount', 'inetOrgPerson'] belongs_to :portal_group, :class_name => 'PortalGroup', :many => 'memberUid' end class PortalGroup < ActiveLdap::Base ldap_mapping :dn_attribute => 'cn',:prefix => "ou=groups", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixGroup'] has_many :portal_users, :class_name => "PortalUser", :wrap => 'memberUid', :primary_key => 'uid' end and my ldap.yaml development: host: 127.0.0.1 port: 1389 base: "ou=users, dc=test, dc=local" bind_dn: "cn=Directory Manager" password: supersecret If i try to create a user using u = PortalUser.new('test') and then look at u.base it's trying to create the user in ou=PortalUsers,ou=users,dc=test,dc=local when I want it in ou=customers, ou=users,dc=test,dc=local Unfortunately there's already models for customers and groups, so I can't just use those models. Any ideas or suggestions would be greatly appreciated. -Steve From kou at cozmixng.org Sat Mar 3 13:35:28 2012 From: kou at cozmixng.org (Kouhei Sutou) Date: Sat, 03 Mar 2012 22:35:28 +0900 (JST) Subject: [activeldap-discuss] how to change default mapping to ldap ou In-Reply-To: References: Message-ID: <20120303.223528.2051000584286997305.kou@cozmixng.org> Hi, In "[activeldap-discuss] how to change default mapping to ldap ou" on Thu, 1 Mar 2012 16:41:23 +0000, Steve Bell wrote: > ou=customers, ou=users, dc=test, dc=local (this is where the users are stored) > ou=groups, ou=users, dc=test, dc=local (this is where the groups are created) > > The models that I have created are: > > class PortalUser < ActiveLdap::Base > ldap_mapping :dn_attribute => 'uid',:prefix => "ou=customers", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixAccount', 'inetOrgPerson'] Please remove the latter :prefix. > belongs_to :portal_group, :class_name => 'PortalGroup', :many => 'memberUid' > end > class PortalGroup < ActiveLdap::Base > ldap_mapping :dn_attribute => 'cn',:prefix => "ou=groups", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixGroup'] Please remove the latter :prefix too. > has_many :portal_users, :class_name => "PortalUser", :wrap => 'memberUid', :primary_key => 'uid' > end Thanks, -- kou From steve at wasabidesigns.co.uk Tue Mar 6 14:23:39 2012 From: steve at wasabidesigns.co.uk (Steve Bell) Date: Tue, 6 Mar 2012 14:23:39 +0000 Subject: [activeldap-discuss] how to change default mapping to ldap ou In-Reply-To: <20120303.223528.2051000584286997305.kou@cozmixng.org> References: <20120303.223528.2051000584286997305.kou@cozmixng.org> Message-ID: <6E146753-A5A5-49A4-A65F-A02A1A208961@wasabidesigns.co.uk> Thanks kou, hadn;t spotted the bad copy and paste. However this results in a base of ou=PortalUsers, ou=users, dc=test, dc=local whereas I want ou=customers, ou=users, dc=test, dc=local. Any way to change the mapping so that the ou that the class maps to in LDAP is different to the class name? -Steve On 3 Mar 2012, at 13:35, Kouhei Sutou wrote: > Hi, > > In > "[activeldap-discuss] how to change default mapping to ldap ou" on Thu, 1 Mar 2012 16:41:23 +0000, > Steve Bell wrote: > >> ou=customers, ou=users, dc=test, dc=local (this is where the users are stored) >> ou=groups, ou=users, dc=test, dc=local (this is where the groups are created) >> >> The models that I have created are: >> >> class PortalUser < ActiveLdap::Base >> ldap_mapping :dn_attribute => 'uid',:prefix => "ou=customers", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixAccount', 'inetOrgPerson'] > > Please remove the latter :prefix. > >> belongs_to :portal_group, :class_name => 'PortalGroup', :many => 'memberUid' >> end > >> class PortalGroup < ActiveLdap::Base >> ldap_mapping :dn_attribute => 'cn',:prefix => "ou=groups", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixGroup'] > > Please remove the latter :prefix too. > >> has_many :portal_users, :class_name => "PortalUser", :wrap => 'memberUid', :primary_key => 'uid' >> end > > > Thanks, > -- > kou > _______________________________________________ > ruby-activeldap-discuss mailing list > ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at wasabidesigns.co.uk Tue Mar 6 14:27:56 2012 From: steve at wasabidesigns.co.uk (Steve Bell) Date: Tue, 6 Mar 2012 14:27:56 +0000 Subject: [activeldap-discuss] how to change default mapping to ldap ou In-Reply-To: <6E146753-A5A5-49A4-A65F-A02A1A208961@wasabidesigns.co.uk> References: <20120303.223528.2051000584286997305.kou@cozmixng.org> <6E146753-A5A5-49A4-A65F-A02A1A208961@wasabidesigns.co.uk> Message-ID: <3924718D-99ED-4F17-9DAC-B41CB3B519D3@wasabidesigns.co.uk> Sorry, my bad. A fresh re-read of the documentation showed it was the prefix that I needed to change. -Steve On 6 Mar 2012, at 14:23, Steve Bell wrote: > Thanks kou, hadn;t spotted the bad copy and paste. > > However this results in a base of ou=PortalUsers, ou=users, dc=test, dc=local whereas I want ou=customers, ou=users, dc=test, dc=local. Any way to change the mapping so that the ou that the class maps to in LDAP is different to the class name? > > -Steve > > On 3 Mar 2012, at 13:35, Kouhei Sutou wrote: > >> Hi, >> >> In >> "[activeldap-discuss] how to change default mapping to ldap ou" on Thu, 1 Mar 2012 16:41:23 +0000, >> Steve Bell wrote: >> >>> ou=customers, ou=users, dc=test, dc=local (this is where the users are stored) >>> ou=groups, ou=users, dc=test, dc=local (this is where the groups are created) >>> >>> The models that I have created are: >>> >>> class PortalUser < ActiveLdap::Base >>> ldap_mapping :dn_attribute => 'uid',:prefix => "ou=customers", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixAccount', 'inetOrgPerson'] >> >> Please remove the latter :prefix. >> >>> belongs_to :portal_group, :class_name => 'PortalGroup', :many => 'memberUid' >>> end >> >>> class PortalGroup < ActiveLdap::Base >>> ldap_mapping :dn_attribute => 'cn',:prefix => "ou=groups", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixGroup'] >> >> Please remove the latter :prefix too. >> >>> has_many :portal_users, :class_name => "PortalUser", :wrap => 'memberUid', :primary_key => 'uid' >>> end >> >> >> Thanks, >> -- >> kou >> _______________________________________________ >> ruby-activeldap-discuss mailing list >> ruby-activeldap-discuss at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: From craig.white at ttiltd.com Tue Mar 6 16:00:46 2012 From: craig.white at ttiltd.com (Craig White) Date: Tue, 6 Mar 2012 09:00:46 -0700 Subject: [activeldap-discuss] how to change default mapping to ldap ou In-Reply-To: <6E146753-A5A5-49A4-A65F-A02A1A208961@wasabidesigns.co.uk> References: <20120303.223528.2051000584286997305.kou@cozmixng.org> <6E146753-A5A5-49A4-A65F-A02A1A208961@wasabidesigns.co.uk> Message-ID: <27789E2C-6B93-47CB-A241-279D6E487A2E@ttiltd.com> Why wouldn't you just have a class called 'Customer' ? Craig On Mar 6, 2012, at 7:23 AM, Steve Bell wrote: > Thanks kou, hadn;t spotted the bad copy and paste. > > However this results in a base of ou=PortalUsers, ou=users, dc=test, dc=local whereas I want ou=customers, ou=users, dc=test, dc=local. Any way to change the mapping so that the ou that the class maps to in LDAP is different to the class name? > > -Steve > > On 3 Mar 2012, at 13:35, Kouhei Sutou wrote: > >> Hi, >> >> In >> "[activeldap-discuss] how to change default mapping to ldap ou" on Thu, 1 Mar 2012 16:41:23 +0000, >> Steve Bell wrote: >> >>> ou=customers, ou=users, dc=test, dc=local (this is where the users are stored) >>> ou=groups, ou=users, dc=test, dc=local (this is where the groups are created) >>> >>> The models that I have created are: >>> >>> class PortalUser < ActiveLdap::Base >>> ldap_mapping :dn_attribute => 'uid',:prefix => "ou=customers", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixAccount', 'inetOrgPerson'] >> >> Please remove the latter :prefix. >> >>> belongs_to :portal_group, :class_name => 'PortalGroup', :many => 'memberUid' >>> end >> >>> class PortalGroup < ActiveLdap::Base >>> ldap_mapping :dn_attribute => 'cn',:prefix => "ou=groups", :prefix => "ou=users, dc=test, dc=local", :classes => ['top', 'posixGroup'] >> >> Please remove the latter :prefix too. >> >>> has_many :portal_users, :class_name => "PortalUser", :wrap => 'memberUid', :primary_key => 'uid' >>> end >> >> >> Thanks, >> -- >> kou >> _______________________________________________ >> ruby-activeldap-discuss mailing list >> ruby-activeldap-discuss at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss > > _______________________________________________ > ruby-activeldap-discuss mailing list > ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss -- Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white at ttiltd.com 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com Need help communicating between generations at work to achieve your desired success? Let us help! From craig.white at ttiltd.com Tue Mar 6 16:02:36 2012 From: craig.white at ttiltd.com (Craig White) Date: Tue, 6 Mar 2012 09:02:36 -0700 Subject: [activeldap-discuss] pagination In-Reply-To: <4A9190A8-1BB6-486B-97B4-64C49F34FB52@ttiltd.com> References: <4A9190A8-1BB6-486B-97B4-64C49F34FB52@ttiltd.com> Message-ID: Any chance that this patch can make it into future releases so I can use ActiveLDAP without resorting to patching on each deployment? Craig On Dec 8, 2011, at 11:43 AM, Craig White wrote: > > On Dec 7, 2011, at 10:49 AM, Ted Lepich wrote: > >> Fyi, I was able to get WIllPaginate to work by adding an :offset parameter to ActiveLdap find_every. >> >> Note: This is from activeldap-1.2.2 (I haven't had a chance to upgrade this application yet). >> >> This required a couple changes to operations.rb. >> >> 25c25 >> < :sort_by, :order, :connection, :base] >> --- >>> :sort_by, :order, :connection, :base, :offset] >> 282a283 >>> offset = options.delete(:offset) || offset >> --- >> 296a307 >>> results = results[offset, results.size] if offset >> >> >> Then in my rails controllers I can do something like this: >> ========================================= >> >> def index >> if params['sort'].blank? then sort = 'myName' else sort = params['sort'] end >> if params['order'].blank? then order = 'ascend' else order = params['order'] end >> params[:page] = 1 if params[:page].blank? >> perpage = session[:perpage] || 20 >> >> @people = WillPaginate::Collection.create(params[:page], perpage) do |pager| >> result = Person.find(:all, :sort_by => sort, :order => order, :limit => pager.per_page, :offset => pager.offset) >> # inject the result array into the paginated collection: >> pager.replace(result) >> >> unless pager.total_entries >> # the pager didn't manage to guess the total count, do it manually >> pager.total_entries = Person.count >> end >> end >> >> respond_to do |format| >> format.html do >> if (request.xhr?) >> render(:update) do |page| >> page.replace_html 'record-list', :partial => 'list', :layout => false >> end >> end >> end >> >> >> >> And this at the bottom of my view (_list partial in my case) add this: >> >> <%= will_paginate @people %> > ---- > activeldap version 3.1.1 > > That does seem to work... > > # diff -u operations.rb-dist operations.rb > --- operations.rb-dist 2011-12-08 11:03:55.632851232 -0700 > +++ operations.rb 2011-12-08 11:28:23.377099818 -0700 > @@ -22,7 +22,7 @@ > module Common > VALID_SEARCH_OPTIONS = [:attribute, :value, :filter, :prefix, > :classes, :scope, :limit, :attributes, > - :sort_by, :order, :connection, :base] > + :sort_by, :order, :connection, :base, :offset] > > def search(options={}, &block) > validate_search_options(options) > @@ -280,6 +280,7 @@ > sort_by = options.delete(:sort_by) || self.sort_by > order = options.delete(:order) || self.order > limit = options.delete(:limit) if sort_by or order > + offset = options.delete(:offset) || offset > options[:attributes] |= ["objectClass"] if options[:attributes] > > results = search(options).collect do |dn, attrs| > @@ -295,6 +296,7 @@ > end > > results.reverse! if normalize_sort_order(order || "ascend") == :descend > + results = results[offset, results.size] if offset > results = results[0, limit] if limit > results > end > > Had to make sure that the 'if offset' line is before the 'if limit' line because that seems to always be true. > > Since I made a lot of adjustments to live without will_paginate, I will have to put this on the side for the moment as I am knee deep in jquery so I am back to my old people_controller until I get a chance to integrate what I have done for column view/sorting and life without pagination into what is now possible but in the meantime, this allows me to verify that it won't break activeldap (and so far it hasn't). I didn't want to let any more time pass without acknowledging this valuable assistance though. > > I would think that this would be a very welcome change to the activeldap source since it actually allows will_paginate to work with activeldap models. > > Thanks > > Craig -- Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white at ttiltd.com 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com Need help communicating between generations at work to achieve your desired success? Let us help! From kou at cozmixng.org Wed Mar 7 09:16:08 2012 From: kou at cozmixng.org (Kouhei Sutou) Date: Wed, 07 Mar 2012 18:16:08 +0900 (JST) Subject: [activeldap-discuss] pagination In-Reply-To: References: <4A9190A8-1BB6-486B-97B4-64C49F34FB52@ttiltd.com> Message-ID: <20120307.181608.1694315312933521814.kou@cozmixng.org> Hi, In "Re: [activeldap-discuss] pagination" on Tue, 6 Mar 2012 09:02:36 -0700, Craig White wrote: > Any chance that this patch can make it into future releases so I can use ActiveLDAP without resorting to patching on each deployment? Could you send a pull request on GitHub? I'll merge it! Thanks, -- kou > Craig > > On Dec 8, 2011, at 11:43 AM, Craig White wrote: > >> >> On Dec 7, 2011, at 10:49 AM, Ted Lepich wrote: >> >>> Fyi, I was able to get WIllPaginate to work by adding an :offset parameter to ActiveLdap find_every. >>> >>> Note: This is from activeldap-1.2.2 (I haven't had a chance to upgrade this application yet). >>> >>> This required a couple changes to operations.rb. >>> >>> 25c25 >>> < :sort_by, :order, :connection, :base] >>> --- >>>> :sort_by, :order, :connection, :base, :offset] >>> 282a283 >>>> offset = options.delete(:offset) || offset >>> --- >>> 296a307 >>>> results = results[offset, results.size] if offset >>> >>> >>> Then in my rails controllers I can do something like this: >>> ========================================= >>> >>> def index >>> if params['sort'].blank? then sort = 'myName' else sort = params['sort'] end >>> if params['order'].blank? then order = 'ascend' else order = params['order'] end >>> params[:page] = 1 if params[:page].blank? >>> perpage = session[:perpage] || 20 >>> >>> @people = WillPaginate::Collection.create(params[:page], perpage) do |pager| >>> result = Person.find(:all, :sort_by => sort, :order => order, :limit => pager.per_page, :offset => pager.offset) >>> # inject the result array into the paginated collection: >>> pager.replace(result) >>> >>> unless pager.total_entries >>> # the pager didn't manage to guess the total count, do it manually >>> pager.total_entries = Person.count >>> end >>> end >>> >>> respond_to do |format| >>> format.html do >>> if (request.xhr?) >>> render(:update) do |page| >>> page.replace_html 'record-list', :partial => 'list', :layout => false >>> end >>> end >>> end >>> >>> >>> >>> And this at the bottom of my view (_list partial in my case) add this: >>> >>> <%= will_paginate @people %> >> ---- >> activeldap version 3.1.1 >> >> That does seem to work... >> >> # diff -u operations.rb-dist operations.rb >> --- operations.rb-dist 2011-12-08 11:03:55.632851232 -0700 >> +++ operations.rb 2011-12-08 11:28:23.377099818 -0700 >> @@ -22,7 +22,7 @@ >> module Common >> VALID_SEARCH_OPTIONS = [:attribute, :value, :filter, :prefix, >> :classes, :scope, :limit, :attributes, >> - :sort_by, :order, :connection, :base] >> + :sort_by, :order, :connection, :base, :offset] >> >> def search(options={}, &block) >> validate_search_options(options) >> @@ -280,6 +280,7 @@ >> sort_by = options.delete(:sort_by) || self.sort_by >> order = options.delete(:order) || self.order >> limit = options.delete(:limit) if sort_by or order >> + offset = options.delete(:offset) || offset >> options[:attributes] |= ["objectClass"] if options[:attributes] >> >> results = search(options).collect do |dn, attrs| >> @@ -295,6 +296,7 @@ >> end >> >> results.reverse! if normalize_sort_order(order || "ascend") == :descend >> + results = results[offset, results.size] if offset >> results = results[0, limit] if limit >> results >> end >> >> Had to make sure that the 'if offset' line is before the 'if limit' line because that seems to always be true. >> >> Since I made a lot of adjustments to live without will_paginate, I will have to put this on the side for the moment as I am knee deep in jquery so I am back to my old people_controller until I get a chance to integrate what I have done for column view/sorting and life without pagination into what is now possible but in the meantime, this allows me to verify that it won't break activeldap (and so far it hasn't). I didn't want to let any more time pass without acknowledging this valuable assistance though. >> >> I would think that this would be a very welcome change to the activeldap source since it actually allows will_paginate to work with activeldap models. >> >> Thanks >> >> Craig > > -- > Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white at ttiltd.com > 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com > > Need help communicating between generations at work to achieve your desired success? Let us help! > > _______________________________________________ > ruby-activeldap-discuss mailing list > ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss From craig.white at ttiltd.com Wed Mar 7 16:16:57 2012 From: craig.white at ttiltd.com (Craig White) Date: Wed, 7 Mar 2012 09:16:57 -0700 Subject: [activeldap-discuss] pagination In-Reply-To: <20120307.181608.1694315312933521814.kou@cozmixng.org> References: <4A9190A8-1BB6-486B-97B4-64C49F34FB52@ttiltd.com> <20120307.181608.1694315312933521814.kou@cozmixng.org> Message-ID: OK - never did it before but it seems that I got it done. Seems there's still a reliance upon activemodel ~> 3.1.0 which hampered my efforts to get to rails 3.2.1 ;-) (I don't know enough to know whether I can just adjust the gemspec or if more needs to be done). Thanks Craig On Mar 7, 2012, at 2:16 AM, Kouhei Sutou wrote: > Hi, > > In > "Re: [activeldap-discuss] pagination" on Tue, 6 Mar 2012 09:02:36 -0700, > Craig White wrote: > >> Any chance that this patch can make it into future releases so I can use ActiveLDAP without resorting to patching on each deployment? > > Could you send a pull request on GitHub? > I'll merge it! > > Thanks, > -- > kou > >> Craig >> >> On Dec 8, 2011, at 11:43 AM, Craig White wrote: >> >>> >>> On Dec 7, 2011, at 10:49 AM, Ted Lepich wrote: >>> >>>> Fyi, I was able to get WIllPaginate to work by adding an :offset parameter to ActiveLdap find_every. >>>> >>>> Note: This is from activeldap-1.2.2 (I haven't had a chance to upgrade this application yet). >>>> >>>> This required a couple changes to operations.rb. >>>> >>>> 25c25 >>>> < :sort_by, :order, :connection, :base] >>>> --- >>>>> :sort_by, :order, :connection, :base, :offset] >>>> 282a283 >>>>> offset = options.delete(:offset) || offset >>>> --- >>>> 296a307 >>>>> results = results[offset, results.size] if offset >>>> >>>> >>>> Then in my rails controllers I can do something like this: >>>> ========================================= >>>> >>>> def index >>>> if params['sort'].blank? then sort = 'myName' else sort = params['sort'] end >>>> if params['order'].blank? then order = 'ascend' else order = params['order'] end >>>> params[:page] = 1 if params[:page].blank? >>>> perpage = session[:perpage] || 20 >>>> >>>> @people = WillPaginate::Collection.create(params[:page], perpage) do |pager| >>>> result = Person.find(:all, :sort_by => sort, :order => order, :limit => pager.per_page, :offset => pager.offset) >>>> # inject the result array into the paginated collection: >>>> pager.replace(result) >>>> >>>> unless pager.total_entries >>>> # the pager didn't manage to guess the total count, do it manually >>>> pager.total_entries = Person.count >>>> end >>>> end >>>> >>>> respond_to do |format| >>>> format.html do >>>> if (request.xhr?) >>>> render(:update) do |page| >>>> page.replace_html 'record-list', :partial => 'list', :layout => false >>>> end >>>> end >>>> end >>>> >>>> >>>> >>>> And this at the bottom of my view (_list partial in my case) add this: >>>> >>>> <%= will_paginate @people %> >>> ---- >>> activeldap version 3.1.1 >>> >>> That does seem to work... >>> >>> # diff -u operations.rb-dist operations.rb >>> --- operations.rb-dist 2011-12-08 11:03:55.632851232 -0700 >>> +++ operations.rb 2011-12-08 11:28:23.377099818 -0700 >>> @@ -22,7 +22,7 @@ >>> module Common >>> VALID_SEARCH_OPTIONS = [:attribute, :value, :filter, :prefix, >>> :classes, :scope, :limit, :attributes, >>> - :sort_by, :order, :connection, :base] >>> + :sort_by, :order, :connection, :base, :offset] >>> >>> def search(options={}, &block) >>> validate_search_options(options) >>> @@ -280,6 +280,7 @@ >>> sort_by = options.delete(:sort_by) || self.sort_by >>> order = options.delete(:order) || self.order >>> limit = options.delete(:limit) if sort_by or order >>> + offset = options.delete(:offset) || offset >>> options[:attributes] |= ["objectClass"] if options[:attributes] >>> >>> results = search(options).collect do |dn, attrs| >>> @@ -295,6 +296,7 @@ >>> end >>> >>> results.reverse! if normalize_sort_order(order || "ascend") == :descend >>> + results = results[offset, results.size] if offset >>> results = results[0, limit] if limit >>> results >>> end >>> >>> Had to make sure that the 'if offset' line is before the 'if limit' line because that seems to always be true. >>> >>> Since I made a lot of adjustments to live without will_paginate, I will have to put this on the side for the moment as I am knee deep in jquery so I am back to my old people_controller until I get a chance to integrate what I have done for column view/sorting and life without pagination into what is now possible but in the meantime, this allows me to verify that it won't break activeldap (and so far it hasn't). I didn't want to let any more time pass without acknowledging this valuable assistance though. >>> >>> I would think that this would be a very welcome change to the activeldap source since it actually allows will_paginate to work with activeldap models. >>> >>> Thanks >>> >>> Craig >> >> -- >> Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white at ttiltd.com >> 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com >> >> Need help communicating between generations at work to achieve your desired success? Let us help! >> >> _______________________________________________ >> ruby-activeldap-discuss mailing list >> ruby-activeldap-discuss at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss > _______________________________________________ > ruby-activeldap-discuss mailing list > ruby-activeldap-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss -- Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white at ttiltd.com 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com Need help communicating between generations at work to achieve your desired success? Let us help! From kou at cozmixng.org Thu Mar 8 12:23:48 2012 From: kou at cozmixng.org (Kouhei Sutou) Date: Thu, 08 Mar 2012 21:23:48 +0900 (JST) Subject: [activeldap-discuss] pagination In-Reply-To: References: <20120307.181608.1694315312933521814.kou@cozmixng.org> Message-ID: <20120308.212348.966420149959116997.kou@cozmixng.org> Hi, In "Re: [activeldap-discuss] pagination" on Wed, 7 Mar 2012 09:16:57 -0700, Craig White wrote: > OK - never did it before but it seems that I got it done. Thanks! I've merged it! > Seems there's still a reliance upon activemodel ~> 3.1.0 which hampered my efforts to get to rails 3.2.1 ;-) (I don't know enough to know whether I can just adjust the gemspec or if more needs to be done). If you can also contribute about Rails 3.2.1 support, could you see the following issue? There are some works what we should do for supporting Rails 3.2.1. https://github.com/activeldap/activeldap/issues/35 Thanks, -- kou