summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-01-31 11:45:53 +0100
committermr <mr@mrautenberg.de>2011-01-31 11:45:53 +0100
commita64ce9f2e9c13b8f644bd75800ee6b1cd9942066 (patch)
treeccaffc933e870368b04083970d38eabc64548789 /application.rb
parent3203db9d2b47d0ac86c74829193f6e53e5eb76a8 (diff)
edit model name
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/application.rb b/application.rb
index 31bab62..2126a48 100644
--- a/application.rb
+++ b/application.rb
@@ -81,6 +81,38 @@ get '/model/:id/status/?' do
end
end
+get '/model/:id/name/?' do
+ response['Content-Type'] = 'text/plain'
+ model = ToxCreateModel.get(params[:id])
+ begin
+ case params[:mode]
+ when 'edit'
+ haml :model_name_edit, :locals=>{:model=>model}, :layout => false
+ when 'show'
+ haml :model_name, :locals=>{:model=>model}, :layout => false
+ else
+ params.inspect
+ end
+ rescue
+ return "unavailable"
+ end
+end
+
+put '/model/:id/?' do
+ response['Content-Type'] = 'text/plain'
+ model = ToxCreateModel.get(params[:id])
+ begin
+ if params[:name] && model.name != params[:name]
+ model.name = params[:name]
+ model.save
+ end
+ redirect url_for("/model/#{model.id}/name?mode=show")
+ rescue
+ return "unavailable"
+ end
+end
+
+
get '/model/:id/:view/?' do
response['Content-Type'] = 'text/plain'
model = ToxCreateModel.get(params[:id])