From 6fb392fa3738843302d78e894df85f7bf967ad48 Mon Sep 17 00:00:00 2001 From: Godwin Date: Fri, 11 Jul 2014 21:15:23 -0600 Subject: [PATCH] Fix for invalid slugs, force trailing slash --- app/controllers/conferences_controller.rb | 16 ++++++++-------- app/views/conferences/index.html.haml | 2 ++ config/application.rb | 1 + lib/tasks/migrate.rake | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 4bf2410..1e2a6eb 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -6,16 +6,18 @@ class ConferencesController < ApplicationController # GET /conferences def index - #Conference.all.each {|m| m.poster.recreate_versions!} - puts " ------------- CONFERENCE INDEX -------------- " - puts params - @conferences = Conference.all + #puts params + @conference_type = nil + if params['conference_type'] + @conference_type = ConferenceType.find_by!(:slug => params['conference_type']) + @conferences = Conference.where(:conference_type_id => @conference_type.id) + else + @conferences = Conference.all + end end # GET /conferences/1 def show - puts " --------------------------- " - puts params[:slug] end # GET /conferences/new @@ -177,8 +179,6 @@ class ConferencesController < ApplicationController # Use callbacks to share common setup or constraints between actions. def set_conference @conference = nil - puts ' ---------------------- ' - puts params if type = ConferenceType.find_by!(slug: params[:conference_type] || params[:conference_type_slug] || 'bikebike') if @conference = Conference.find_by!(slug: params[:conference_slug] || params[:slug], conference_type_id: type.id) set_conference_registration diff --git a/app/views/conferences/index.html.haml b/app/views/conferences/index.html.haml index 9d6fc74..d883d04 100644 --- a/app/views/conferences/index.html.haml +++ b/app/views/conferences/index.html.haml @@ -6,6 +6,8 @@ .columns %h1=_'page.Conferences' +%h2='All '+(@conference_type ? @conference_type.title+' ' : '')+' Conferences' + %ul.small-block-grid-1.medium-block-grid-2.large-block-grid-3.conference-list.preview-list - @conferences.each do |conference| %li=render 'preview', :conference => conference diff --git a/config/application.rb b/config/application.rb index 48d0fc0..f73262d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -26,6 +26,7 @@ module BikeBike # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] config.i18n.default_locale = :en #:de config.i18n.enforce_available_locales = false + config.action_controller.default_url_options = { :trailing_slash => true } #config.middleware.swap 'Rack::MethodOverride', 'Rack::MethodOverrideWithParams' #config.i18n.exception_handler = I18n::MissingTranslationExceptionHandler.new #require '/app/helpers/bike_bike_form_helper' diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index e16a885..9648d29 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -119,7 +119,7 @@ namespace :migrate do { :id => id, :name => object[:title], - :slug => object[:path].gsub(/^.*\/(.*)$/, '\1'), + :slug => object[:path].gsub(/^.*\/(.*)$/, '\1').gsub(/[\.\#\?\!]/, ''), :email_address => object[:email] && object[:email].first ? object[:email]['und'][0]['url'] : nil, :url => object[:field_website] && object[:field_website].first ? object[:field_website]['und'][0]['url'] : nil, :year_founded => object[:field_year_founded] && object[:field_year_founded].first ? object[:field_year_founded]['und'][0]['value'] : nil,