Browse Source

Fix for invalid slugs, force trailing slash

development
Godwin 11 years ago
parent
commit
6fb392fa37
  1. 16
      app/controllers/conferences_controller.rb
  2. 2
      app/views/conferences/index.html.haml
  3. 1
      config/application.rb
  4. 2
      lib/tasks/migrate.rake

16
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

2
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

1
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'

2
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,

Loading…
Cancel
Save