Last active
          August 29, 2015 14:01 
        
      - 
      
 - 
        
Save chrisun/2bc7f31943e1ba346bc5 to your computer and use it in GitHub Desktop.  
    Make a Datagrid column into a link
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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