How to have several restrictions in Rails routes.rb?

I need a rails route that takes into account 2 restrictions. How can this be done? Two limitations

match ':id' => 'pages#temp', :constraints => { :uuid => /[A-Za-z\d]([-\w]{,498}[A-Za-z\d])?/ } root :to => 'pages#temp', :constraints => lambda {|r| r.env["warden"].authenticate? } 

How can I use one of these methods with two restrictions? Thanks

 match ':id' => 'pages#temp', :constraints => 
+6
source share
1 answer

I think you will need to create your own class of restrictions and put all your restrictions. For more information, see Advanced Constraints in Guide Guides (link below).

http://guides.rubyonrails.org/routing.html#advanced-constraints

+1
source

Source: https://habr.com/ru/post/919188/


All Articles