class Account < ActiveRecord::Base INVALID_PAGE_NAMES = Dir[Rails.root.join('app/controllers/*_controller.rb')].map { |path| path.match(/(\w+)_controller.rb/); $1 } validates :page_name, :exclusion => { :in => INVALID_PAGE_NAMES, :message => "Page %{value} is reserved." } end
Tech stuff around computer programming, basically for web development, especially opensource. Topics will go round Ruby on Rails (git gems etc.), Ubuntu (admin and basic shell) and work organization (agile philosophy)
Sunday, 24 February 2013
validates exclusion of controller names when catching all routes
Of course catching all routes is bad, but if you have to:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment