Friday 15 March 2013

Use Will_paginate with hash keys in Rails -



Use Will_paginate with hash keys in Rails -

i have hash keys objects, , values arrays of objects. in view want show list these objects in keys , paginate them. will_paginate doesn't seems work hashes...

here's controller:

@hash = hash.new articles_pending_review.each |a| duplicates_ids = json.parse(a.properties)["duplicates"].split(',').collect! {|n| n.to_i} duplicates_ids.each |d| article = article.unscoped.find(d) @hash[article] = [] if !@hash[article] @hash[article].push(a) unless @hash[article].include?(a) end end

and view:

%ul.articles_list - @hash.each |article_key, duplicates_array| %li %p= article_key.name %ul.article_duplicates_list - duplicates_array.each |d| %li= d.name

i've found similar questions don't know how apply them in case. help me? thanks!

you have utilize custom pagination, e.g:

@paginated_articles = willpaginate::collection.create(current_page, per_page, total) |pager| pager.replace @hash.keys end

see here more info.

ruby-on-rails hash will-paginate

No comments:

Post a Comment