Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DictionaryPresenter
- include Enumerable
- def initialize(collection)
- @dictionary = ('A'..'Z').each_with_object({}){|l,h| h[l] = []}
- collection.each{|p| @dictionary[p.title[0]] << p}
- end
- def each &block
- @dictionary.each(&block)
- end
- end
- @posts = DictionaryPresenter.new(Post.all).as_dictionary
- # changed to this
- @posts = DictionaryPresenter.new(Post.all)
Add Comment
Please, Sign In to add comment