Browse Source

Fix for invalid slugs, force trailing slash

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

14
app/controllers/conferences_controller.rb

@ -6,16 +6,18 @@ class ConferencesController < ApplicationController
# GET /conferences # GET /conferences
def index def index
#Conference.all.each {|m| m.poster.recreate_versions!} #puts params
puts " ------------- CONFERENCE INDEX -------------- " @conference_type = nil
puts params 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 @conferences = Conference.all
end end
end
# GET /conferences/1 # GET /conferences/1
def show def show
puts " --------------------------- "
puts params[:slug]
end end
# GET /conferences/new # GET /conferences/new
@ -177,8 +179,6 @@ class ConferencesController < ApplicationController
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_conference def set_conference
@conference = nil @conference = nil
puts ' ---------------------- '
puts params
if type = ConferenceType.find_by!(slug: params[:conference_type] || params[:conference_type_slug] || 'bikebike') 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) if @conference = Conference.find_by!(slug: params[:conference_slug] || params[:slug], conference_type_id: type.id)
set_conference_registration set_conference_registration

2
app/views/conferences/index.html.haml

@ -6,6 +6,8 @@
.columns .columns
%h1=_'page.Conferences' %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 %ul.small-block-grid-1.medium-block-grid-2.large-block-grid-3.conference-list.preview-list
- @conferences.each do |conference| - @conferences.each do |conference|
%li=render 'preview', :conference => 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.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :en #:de config.i18n.default_locale = :en #:de
config.i18n.enforce_available_locales = false config.i18n.enforce_available_locales = false
config.action_controller.default_url_options = { :trailing_slash => true }
#config.middleware.swap 'Rack::MethodOverride', 'Rack::MethodOverrideWithParams' #config.middleware.swap 'Rack::MethodOverride', 'Rack::MethodOverrideWithParams'
#config.i18n.exception_handler = I18n::MissingTranslationExceptionHandler.new #config.i18n.exception_handler = I18n::MissingTranslationExceptionHandler.new
#require '/app/helpers/bike_bike_form_helper' #require '/app/helpers/bike_bike_form_helper'

2
lib/tasks/migrate.rake

@ -119,7 +119,7 @@ namespace :migrate do
{ {
:id => id, :id => id,
:name => object[:title], :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, :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, :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, :year_founded => object[:field_year_founded] && object[:field_year_founded].first ? object[:field_year_founded]['und'][0]['value'] : nil,

Loading…
Cancel
Save