From 977ca823067f4141e95fcdcec32e4310233400f5 Mon Sep 17 00:00:00 2001 From: bsag Date: Tue, 7 Jun 2005 18:39:51 +0000 Subject: [PATCH] Fixes #62. The problem was that project (and context) names were made into URLs via the 'urlize' method which substituted spaces for underscores and downcased the string. This was then converted back to the real project name by the Rails method 'humanize', which substituted spaces for underscores and Capitalized the string (i.e. only the first word was given an initial capital). This meant that visiting /project/show/project_name would fail if the real project name was either 'Project Name' or 'project name'. I altered 'urlize' to maintain the capitalization that was entered, and created a new method 'deurlize' that just reversed this change (i.e. swapped underscores for spaces, but left capitalization as is). git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@101 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/application.rb | 4 ++++ tracks/app/controllers/context_controller.rb | 2 +- tracks/app/controllers/project_controller.rb | 2 +- tracks/app/helpers/application_helper.rb | 2 +- tracks/db/tracks_1.0.3_content.sql | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index 1972ffd0..084ed171 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -30,4 +30,8 @@ class ApplicationController < ActionController::Base error_messages_for( obj ) unless instance_eval("@#{obj}").nil? end + def deurlize(name) + name.to_s.gsub(/_/, " ") + end + end \ No newline at end of file diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index ab4f3f47..f939248e 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -24,7 +24,7 @@ class ContextController < ApplicationController # e.g. /project/show/ shows just . # def show - @context = Context.find_by_name(@params["name"].humanize) + @context = Context.find_by_name(deurlize(@params["name"])) @places = Context.find(:all, :order => "position ASC") @projects = Project.find(:all, :order => "position ASC") @page_title = "TRACKS::Context: #{@context.name}" diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index 29960fc1..7b9636b0 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -24,7 +24,7 @@ class ProjectController < ApplicationController # e.g. /project/show/ shows just . # def show - @project = Project.find_by_name(@params["name"].humanize) + @project = Project.find_by_name(deurlize(@params["name"])) @places = Context.find(:all, :order => "position ASC") @projects = Project.find(:all, :order => "position ASC") @page_title = "TRACKS::Project: #{@project.name}" diff --git a/tracks/app/helpers/application_helper.rb b/tracks/app/helpers/application_helper.rb index a3d679d2..bfdd012b 100644 --- a/tracks/app/helpers/application_helper.rb +++ b/tracks/app/helpers/application_helper.rb @@ -28,7 +28,7 @@ module ApplicationHelper end def urlize(name) - name.to_s.gsub(/ /, "_").downcase + name.to_s.gsub(/ /, "_") end diff --git a/tracks/db/tracks_1.0.3_content.sql b/tracks/db/tracks_1.0.3_content.sql index 53681ae9..7c3a4512 100644 --- a/tracks/db/tracks_1.0.3_content.sql +++ b/tracks/db/tracks_1.0.3_content.sql @@ -11,7 +11,7 @@ -- ------------------------------------------------------------ INSERT INTO contexts (id,name,hide, position) VALUES (1,'agenda',0, 1); -INSERT INTo contexts (id,name,hide, position) VALUES (2,'call',0, 2); +INSERT INTO contexts (id,name,hide, position) VALUES (2,'call',0, 2); INSERT INTO contexts (id,name,hide, position) VALUES (3,'email',0, 3); INSERT INTO contexts (id,name,hide, position) VALUES (4,'errand',0, 4); INSERT INTO contexts (id,name,hide, position) VALUES (5,'lab',0, 5);