简体   繁体   中英

Rails: restful resource routing with action_controller_path

I am putting a randomize def in my controller and would like to access it with a restful route. The route should be accessed with the following:

<%= link_to "Randomize", random_reader_path %>

But I cannot figure out how to get this route to appear in rake routes or configure it correctly in my routes.rb file.

The random method will do the same thing as index only provide a random page content @variable

Currently I have my reader Controller as

resources :reader

in my routes.rb

Add more RESTful actions !

resources :reader do
  get 'random', on: :collection
end

The route will be random_readers_path , though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM