From 4c50eb786ebf7824c5d4f014211bccbc7379020b Mon Sep 17 00:00:00 2001 From: f Date: Thu, 27 Sep 2018 15:17:10 -0300 Subject: [PATCH] el id del sitio puede contener puntos --- app/models/site.rb | 11 +++-------- config/routes.rb | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index 14e0b4a1..e410d223 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -56,20 +56,15 @@ class Site # Obtener el nombre del sitio def name - @name ||= @jekyll.config['source'].split('/').last + @name ||= File.basename(@jekyll.config['source']) end + alias :id :name + alias :to_s :name def name_with_i18n(lang) [name, lang].join('/') end - # El id es el sitio sin puntos, para no confundir al routeador de - # rails - def id - @id ||= name.tr('.', '-') - end - alias :to_s :id - def read @jekyll.read end diff --git a/config/routes.rb b/config/routes.rb index 126f5849..3792d851 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,7 +9,7 @@ Rails.application.routes.draw do get '/sites/:site_id/public/:type/:basename', to: 'sites#send_public_file' - resources :sites, only: [ :index, :show ] do + resources :sites, only: [:index, :show], constraints: { site_id: /[^\/]+/, id: /[^\/]+/ } do resources :posts resources :templates