“/#action” Route in Routes.rb in Ruby on Rails

2019-02-21 00:12发布

问题:

How can I create a route of this format (in Ruby on Rails routes.rb file):

/#action/id

Specifically with the "#" character inserted before the action controller...for example, see http://lala.com/#album/some-album-id

thanks!

回答1:

The actual URL you are visiting there is http://lala.com/. The server does not see the #album/some-album-id piece, the fragment identifier. That is seen solely by the browser.

There is a growing trend of building MVC apps with the views and controllers in the client/browser, rather than on the server. The application is implemented with JavaScript in the client, instead of with Ruby on the server. The server essentially becomes the API or the data-access layer, rather than being the piece that renders HTML.