Add validation for item.name, only allow [a-zA-z-_]
This commit is contained in:
parent
ce63c53605
commit
12de9d2514
|
@ -14,6 +14,7 @@ class Item
|
||||||
key :position, Integer, :required => true
|
key :position, Integer, :required => true
|
||||||
key :is_published, Boolean, :required => true, :default => true, :index => true
|
key :is_published, Boolean, :required => true, :default => true, :index => true
|
||||||
|
|
||||||
|
validates_format_of :name, :with => /^[a-zA-Z-_]+$/
|
||||||
belongs_to :parent, :class_name => "Item", :foreign_key => :parent_id
|
belongs_to :parent, :class_name => "Item", :foreign_key => :parent_id
|
||||||
many :children, :class_name => "Item", :foreign_key => :parent_id
|
many :children, :class_name => "Item", :foreign_key => :parent_id
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class RerouteMiddleware
|
||||||
#Rails.logger.debug env.to_yaml
|
#Rails.logger.debug env.to_yaml
|
||||||
return @app.call(env) if env['REQUEST_URI'] =~ /^\/admin/
|
return @app.call(env) if env['REQUEST_URI'] =~ /^\/admin/
|
||||||
|
|
||||||
env['REQUEST_URI'] =~ /^\/([\w]*)/
|
env['REQUEST_URI'] =~ /^\/([a-zA-Z-_]*)/
|
||||||
parsed_entry_name = $1
|
parsed_entry_name = $1
|
||||||
|
|
||||||
entry = Item.find_by_name( parsed_entry_name )
|
entry = Item.find_by_name( parsed_entry_name )
|
||||||
|
|
Loading…
Reference in New Issue