Skip to content

Instantly share code, notes, and snippets.

@chrisun
Last active August 29, 2015 14:01
Show Gist options
  • Save chrisun/2bc7f31943e1ba346bc5 to your computer and use it in GitHub Desktop.
Save chrisun/2bc7f31943e1ba346bc5 to your computer and use it in GitHub Desktop.
Make a Datagrid column into a link
class PostsGrid
include Datagrid
scope do
Post
end
column(:id)
# => /posts/1
column(:title, html: true) do |post|
link_to post.title, post
end
# or to support non-HTML formats such as CSV as well
column(:title) do |post|
format(post.title) do |title|
link_to title, post
end
end
# or
column(:title, url: ->(post) { post })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment