Note that there are some explanatory texts on larger screens.

plurals
  1. POwhere does the url routes get resolved when you call render in rails controller actions
    primarykey
    data
    text
    <p>Is there any method that i should look at in rails3.2 source code so as to know where the navigation or the url part of the render call get resolved? The reason is, i have a small app in which url is of the form </p> <blockquote> <p>www.example.com/bob/edit</p> </blockquote> <p>the above route as it suggests renders the edit form.EDIT: i was able to get to this route by modifying response on the link_to helper.</p> <pre><code>def update #when validation passes redirect_to @user #when validation fails respond_to do |format| format.html {render :action =&gt; "edit"} end end </code></pre> <p>Now the problem is when a validation error occurs on submission to update action of users_controller, the url becomes </p> <blockquote> <p>www.example.com/users/bob/edit</p> </blockquote> <p>config/routes.rb</p> <pre><code>get "users/new", to: =&gt; "users#new" resources :users </code></pre> <p>as you can see there's nothing interesting happening in routes, </p> <p>in models/user.rb</p> <pre><code>def to_param "#{name}" end </code></pre> <p>in views/edit.html.erb</p> <pre><code>form_for(@user) do |f| end </code></pre> <blockquote> <p><strong>Observation:</strong> here when the form is rendered afresh, form 'action' points to "users/bob" but when the form is re-rendered 'cos of validation error, form action mysteriosly changes to "users/" which is weired and if i remove the to_param in user.rb model it works fine </p> </blockquote> <p>Though its not such a big deal, i was thinking where, if i needed to override the url that is generated on render call, to change?????</p> <p>Any suggestions and pointers to explore are wecome....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload