Wednesday, May 28, 2014 Accessing a URL or path directly from a model can help to remove repetition in code. Consider the following: # config/routes.rb get 'posts/:segment/:slug', to: 'posts#show', as: :post # app/views/posts/_preview.html.haml - @posts.each do |post| - # <a href='/posts/2014-05-27/an-example-post'>An Example Post</a> = link_to post.title, posts_path(post, segment: post.segment, s
![Rails Concerns for URL and Path Helpers](https://cdn-ak-scissors.b.st-hatena.com/image/square/71492a421934ebffe638da2f00aa0893feda83cf/height=288;version=1;width=512/https%3A%2F%2Fksylvest.com%2Fassets%2Fprofile%2Fdefault-5babf7464197c2c9ae8d4e9333d375de59ba03fb25f109e11d6f7e9ea39858bb.jpg)