Chronicling my journey and discoveries in cutting-edge software development. Here, I share practical knowledge and solutions, focusing on Ruby on Rails, Node.js, and JavaScript, alongside explorations into Kubernetes, distributed systems, and latest web technologies.
Thanks for sharing. If you are looking Ruby on Rails in India then Cryptex Solutions is the one of the most reputed company in India. We customize canavas LMS, Integrate bitcoin payment gateway and many more. For more details contact us at: info@cryptextechnologies.com
For Truncating String I have used 'truncate' rails helper method. limiting to 10 characters truncate("im srikanth glad to meet you", 10) >> "im srik..." For HTML stripping, I have used gsub.. str.gsub(/ ]*>/, "")
Wanna paginate an Array using will paginate.. Here is how i did.. Add this as method, Array.class_eval do def paginate(page=1, per_page=15) pagination_array = WillPaginate::Collection.new(page, per_page, self.size) start_index = pagination_array.offset end_index = start_index + (per_page - 1) array_to_concat = self[start_index..end_index] array_to_concat.nil? ? [] : pagination_array.concat(array_to_concat) end end And with the array @results do @results.paginate reference: http://www.devchix.com/2007/07/23/will_paginate-array/ Regards, Srikanth Learn to Program with Ruby | Ruby Pocket Reference
Comments