Note that there are some explanatory texts on larger screens.

plurals
  1. PORails appends id to singular route when render edit after errors
    primarykey
    data
    text
    <p>I have the following singular route:</p> <pre><code>scope '/seller' do resource :seller_profile, :path =&gt; "/profile", :only =&gt; [:show, :edit, :update] end </code></pre> <p>and the following controller:</p> <pre><code>class SellerProfilesController &lt; ApplicationController before_filter :validate_user_as_seller def show @seller_profile = current_user.seller_profile end def edit @seller_profile = current_user.seller_profile end def update @seller_profile = current_user.seller_profile if @seller_profile.update_attributes(params[:seller_profile]) redirect_to(seller_profile_path, :notice =&gt; 'Profile was successfully updated.') else render :action =&gt; "edit" end end end </code></pre> <p>I use a singular route given that the user must be authenticated before gaining access to the controller and therefore I can get the seller_profile from the user logged in.</p> <p>This works like a charm, with only one problem. When I edit the seller_profile and validation error happen, the form is edited again and the errors are displayed correctly. The problem is that rails appends to the url the id of the edited record. For instance, when I first edit the record, the url is:</p> <pre><code>http://0.0.0.0:3000/seller/profile/edit </code></pre> <p>but if the form is submitted with validation errors, the form itself is redisplayed under</p> <pre><code>http://0.0.0.0:3000/seller/profile.2 </code></pre> <p>where 2 is the ID of the record being edited.</p> <p>The form is the following:</p> <pre><code>&lt;%= simple_form_for @seller_profile do |f| %&gt; &lt;%= f.input :name %&gt; &lt;%= f.input :description %&gt; &lt;%= f.submit %&gt; &lt;% end %&gt; </code></pre> <p>Everything, as said, works great but I would totally mask the ID in the url. What should I do?</p>
    singulars
    1. This table or related slice is empty.
    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