I want to know if an arbitrary path can be mapped to a route
detected_request_for does what I want, but I cannot get it to work in my controller.
In particular, how can I perform a recognized_for_for or something that performs the same task from my controller?
DECISION:
@related_page_path = '/' + @page.path begin ActionController::Routing::Routes.recognize_path(@related_page_path, :method => :get) rescue @related_page_path = nil end
For Rails 3 Challenge
Rails.application.routes.recognize_path
Instead
ActionController::Routing::Routes.recognize_path
Example:
def path_exists?(path) begin Rails.application.routes.recognize_path(path) rescue return false end true end
, helper- , ( response_to? ).
, map.connect
map.connect
map.connect '/any/random/string/of/stuff', :controller => 'items', :action => 'new'
:
map.connect '/seeking/room/for/[:number_of_nights]/nights', :controller => 'rooms', :action => 'index'
, URL- params .
params
, , , . Rails.application.routes.recognize_path, rails 4.2.1. :
rails 4.2.1
Rails.application.routes.named_routes.routes.any?{ |key, value| key.to_s === "new_article" }
Source: https://habr.com/ru/post/1755154/More articles:What is _acp-sync._tcp bonjour for? - bonjourcss file not loading - cssFancybox event does not fire - c #Simple game server - databaseПростой, единообразный и переносимый способ включения отслеживания и возврата в программу C - cCall C ++ from the assembly loader - c ++Getting Python module nltk.wordnet to work in Jython - pythonTrying to get value from text view in event list view mode in Android - javaBest VM installation for cross-platform and multiprocess development - virtual-machineRuby on Rails server freezes / lags randomly for a long time - ruby-on-railsAll Articles