Skip to content

Instantly share code, notes, and snippets.

View creedian's full-sized avatar

Chris Doucette creedian

View GitHub Profile
@zandroid
zandroid / paginate_helper.rb
Last active September 26, 2017 21:55
This is a custom link renderer that will format the pagination bar with Bootstrap4
module PaginateHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
protected
def html_container(html)
tag(:nav, tag(:ul, html, class: "pagination"))
end
def previous_or_next_page(page, text, classname)
if page
@cdmwebs
cdmwebs / friendly_urls.markdown
Created September 11, 2011 15:50 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.