rest - How to make Ruby on Rails RESTful routes pretty and human friendly? -


With Ruby on Rail, for a developer to simplify things and make resources easier, rest is a great concept is. , But it also creates amazing URL URLs for humans. For example, using a popular restylable authentication plugin to handle user login and authentication, this creates two authentication for authentication and authorization, user and session. The reason for this is that the user is connected to long-term resources such as login and password, while one session represents login information related to session login sessions such as cookie resources. Thus, the login URL site for a site will be / sessions / new.

By default, it also creates a path to help: map.login '/ login',: Controller => 'However, it is actually only a hip, because it works correctly When submitting for routes to use, the form uses <% form_tag session_path do -%>. This causes the form's position to go to session controller #, but if the form submission fails (such as due to bad credentials), then the user's browser is omitted on site.com/session, which actually looks weird Used to be. Even worse, if the user was manually entering that URL, then it is unavailable until I define an index method. If I change the form_tag to read & lt;% form_tag login_path do -%> then this post is in session controller # new, which completely mess up the rest.

How do I keep the constant and proper looking URL? Overall, I'm actually getting the convenience of using REST, but it seems very wrong that it should generate the changes that appear for the user (negative).

I think it provides a consistent, intuitive and user-friendly URL throughout the rest, especially when It comes to reclaiming resources (GET) which is usually what the user wants to do often bookmarks). Typically, you are working with URLs like

  / posts / 34 / articles / 456 / edit / companies  

and inevitable So, very annoying) is the exception, on which I have never seen a real solution, other than using AJAX. The problem is that there are slow passages in such applications which carefully take into account the domain, where the resources on the backend also understand the user (such as the above), while the session management is implicit in the underlying for the user.

If you are unhappy with the / session url, why not surname / login / submit to / sessions / create?


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -