Sha256: 3f2a2ef17faf858e076f4502cd8fe639dd7dceb1e23fa4bd22860a75c72d80c9
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
class Routepath < ActiveRecord::Base belongs_to :function validates :controller, :presence => {:message => "控制器不能为空"} validates :action, :presence => {:message => "动作不能为空"} validates :method, :presence => {:message => "请求方法不能为空"} def self.seed Rails.application.routes.routes.each do |route| controller = route.defaults[:controller] action = route.defaults[:action] #method = "#{route.constraints[:request_method]}".gsub("(?-mix:^","").gsub("$)","") method = route.verb if controller && action && method next if controller.length>=5 && controller[0, 5]=="rails" if Routepath.where(controller: controller, action: action, method: method).blank? puts "create---#{controller}|---#{action}|--#{method}" Routepath.create!(controller: controller, action: action, method: method) end end end return "" end def self.check(controller, action, method=nil) if method.blank? return !Routepath.where(controller: controller, action: action).exists? else return !Routepath.where(controller: controller, action: action, method: method).exists? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
admin-sys-1.1.0 | app/models/routepath.rb |