Minor refactor to preare for arRESTing NoteController.

Also fixed a recently introduced bug that caused projects or contexts with numbers in the name to fail to resolve properly by URL
 


git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@401 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-01-14 19:33:11 +00:00
parent 36fcfe5c59
commit ce2a9e2279
5 changed files with 5 additions and 5 deletions

View file

@ -100,7 +100,7 @@ class ContextsController < ApplicationController
def check_user_set_context
if params['url_friendly_name']
@context = @user.contexts.find_by_url_friendly_name(params['url_friendly_name'])
elsif params['id'] && params['id'] =~ /\d+/
elsif params['id'] && params['id'] =~ /^\d+$/
@context = @user.contexts.find(params['id'])
elsif params['id']
@context = @user.contexts.find_by_url_friendly_name(params['id'])

View file

@ -16,7 +16,7 @@ class NoteController < ApplicationController
# Add a new note to this project
#
def add
def create
note = @user.notes.build
note.attributes = params["new_note"]

View file

@ -115,7 +115,7 @@ class ProjectsController < ApplicationController
def check_user_set_project
if params["url_friendly_name"]
@project = @user.projects.find_by_url_friendly_name(params["url_friendly_name"])
elsif params['id'] && params['id'] =~ /\d+/
elsif params['id'] && params['id'] =~ /^\d+$/
@project = @user.projects.find(params["id"])
elsif params['id']
@project = @user.projects.find_by_url_friendly_name(params["id"])

View file

@ -18,7 +18,7 @@
<div>
<div id="new-note" style="display:none;">
<% form_remote_tag :url => { :controller => "note", :action => "add" },
<% form_remote_tag :url => { :controller => "note", :action => "create" },
:update => "notes",
:position => "bottom",
:complete => "new Effect.Highlight('notes');$('empty-n').hide();",

View file

@ -45,7 +45,7 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'projects/feed/:feedtype/:login/:token', :controller => 'feed', :action => 'list_projects_only'
# Notes Routes
map.connect 'note/add', :controller => 'note', :action => 'add'
map.connect 'note/create', :controller => 'note', :action => 'create'
map.connect 'note/update/:id', :controller => 'note', :action => 'update', :id => 'id'
map.connect 'note/:id', :controller => 'note', :action => 'show', :id => 'id'
map.connect 'notes', :controller => 'note', :action => 'index'