Note that there are some explanatory texts on larger screens.

plurals
  1. PORails 3 - Nested Resources Routing - One to One relationship
    primarykey
    data
    text
    <p>Having some trouble with some nested resources routing. What I'm trying to do is link to a user's profile page for editing purposes. In my view it is written as: </p> <pre><code>&lt;%= link_to "Edit Profile", edit_user_profile_path(current_user) %&gt; </code></pre> <p>Which errors out with:</p> <pre><code>No route matches {:action=&gt;"edit", :controller=&gt;"profiles", :user_id=&gt;#&lt;User id: 1, email: "EDITEDOUT", hashed_password: "EDITEDOUT", created_at: "2011-01-20 18:30:44", updated_at: "2011-01-20 18:30:44"&gt;} </code></pre> <p>In my routes.rb file, it looks like so:</p> <pre><code>resources :users do resources :profiles, :controller =&gt; "profiles" end </code></pre> <p>I checked my Rake routes, and it gave me this as a valid option:</p> <pre><code>edit_user_profile GET /users/:user_id/profiles/:id/edit(.:format) {:action=&gt;"edit", :controller=&gt;"profiles"} </code></pre> <p>Which I am able to manually navigate to. For good measures, here's proof of my controller:</p> <pre><code>class ProfilesController &lt; ApplicationController def edit @user = current_user @profile = current_user.profile end def update @user = current_user @profile = current_user.profile respond_to do |format| if @profile.update_attributes(params[:profile]) format.html { redirect_to(orders_path, :notice =&gt; "Your profile has been updated.") } format.xml { head :ok } else format.html { render :action =&gt; "edit" } format.xml { render :xml =&gt; @profile.errors, :status =&gt; :unprocessable_entity } end end end end </code></pre> <p>Anyway, I've been having some problem tracking this down. Any pointers would help. For my DB design Profiles belong to Users in a one-to-one relationship. I'm hoping it's just something newbish I'm not noticing a new set of eyes might help.</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