Skip to content
Snippets Groups Projects
Commit 1f88e343 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Routes avec la date

parent 37c5d997
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ class Extranet::Posts::PostsController < Extranet::Posts::ApplicationController
end
def show
# TODO utiliser la date pour permettre des slugs identiques à dates différentes
@post = current_extranet.posts.find_by! slug: params[:slug]
breadcrumb
end
......
......@@ -31,7 +31,7 @@
<% content_for :action_bar_right do %>
<%= link_to t('open'),
posts_post_url(@post.slug, host: @post.extranet.url, extranet_id: nil),
posts_post_url(date: @post.published_at.strftime('%Y-%m-%d'), slug: @post.slug, host: @post.extranet.url, extranet_id: nil),
target: :_blank,
class: 'btn btn-light btn-xs' if @post.published %>
<%= preview_link %>
......
......@@ -9,7 +9,9 @@
<b><%= post %></b><br>
<span class="text-muted"><%= l post.published_at.to_date %><span>
</p>
<%= link_to t('extranet.posts.read_post'), posts_post_path(post.slug), class: ' btn btn-outline-primary stretched-link' %>
<%= link_to t('extranet.posts.read_post'),
posts_post_path(date: post.published_at.strftime('%Y-%m-%d'), slug: post.slug),
class: ' btn btn-outline-primary stretched-link' %>
</div>
</article>
<% end %>
......
......@@ -27,7 +27,7 @@ namespace :posts do
get 'categories' => 'categories#index', as: :categories
get 'categories/:slug' => 'categories#show', as: :category
# Categories before slug !
get ':slug' => 'posts#show', as: :post
get ':date/:slug' => 'posts#show', as: :post
root to: 'posts#index'
end
namespace :library do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment