Also limits template name to standard db varchar length of 255
characters. Eventually all the other db string fields should
have this validation
---
src/app/controllers/templates_controller.rb | 6 ++++--
src/app/models/template.rb | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/templates_controller.rb
b/src/app/controllers/templates_controller.rb
index 3373c05..f9eaf5e 100644
--- a/src/app/controllers/templates_controller.rb
+++ b/src/app/controllers/templates_controller.rb
@@ -106,11 +106,13 @@ class TemplatesController < ApplicationController
# synchronize it at first to xml
@tpl.update_xml_attributes(params[:tpl])
- if @tpl.save
+ begin
+ @tpl.save!
flash[:notice] = "Template saved."
@tpl.set_complete
redirect_to :action => 'index'
- else
+ rescue Exception => e
+ flash[:notice] = "There was a problem saving the template: #{e.to_s}"
get_selected_packages(@tpl)
render :action => 'new'
end
diff --git a/src/app/models/template.rb b/src/app/models/template.rb
index 9264e76..e9f2327 100644
--- a/src/app/models/template.rb
+++ b/src/app/models/template.rb
@@ -14,6 +14,7 @@ class Template < ActiveRecord::Base
# unset)
validates_presence_of :name
validates_uniqueness_of :name
+ validates_length_of :name, :maximum => 255
validates_presence_of :platform
validates_presence_of :platform_version
validates_presence_of :architecture
--
1.7.2.3
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel