app/models/picture.rb
# Check if the permalink is possible for the URL /galleries/#{permalink}
# a permalinks static variable is use for performance, because the collect
# of routing is longer
# It the permalink is a route return true
Check if the permalink is possible for the URL /galleries/#{permalink}
a permalinks static variable is use for performance, because the collect
of routing is longer
It the permalink is a route return true
Check if the permalink is possible for the URL / galleries / # { permalink } a permalinks static variable is use for performance because the collect of routing is longer It the permalink is a route return true
def ensure_permalink_is_not_a_route(permalink_test)
    @@permalinks ||= ActionController::Routing::Routes.routes.collect {|r|
      r.segments.last.string_structure(r.segments[0..-2]).match(/"\/pictures\/([\w]+)/)[1] rescue nil
    }.uniq.compact
    @@permalinks.include?(permalink_test)
  end
def ensure_permalink_is_not_a_route ( permalink_test ) @@permalinks ||= ActionController :: Routing :: Routes . routes . collect { | r | r . segments . last . string_structure ( r . segments [ 0 .. - 2 ] ) . match ( / " \/ pictures \/ ([ \w ]+) / ) [ 1 ] rescue nil } . uniq . compact @@permalinks . include? ( permalink_test ) end
Check if the permalink is possible for the URL /galleries/#{permalink}
a permalinks static variable is use for performance, because the collect
of routing is longer
It the permalink is a route return true
Check if the permalink is possible for the URL / galleries / # { permalink } a permalinks static variable is use for performance because the collect of routing is longer It the permalink is a route return true
permalink_test
<not_specific>