ruby - Rails -Couldn't find User with 'id'= -


i've been developing site based on hartl's guide. want move password reset functionality own partial.

i created partial, _passreset.html.erb. copy of _form shows username , displays password/password_confirm fields.

but i'm not getting there. on show.html.erb page (the profile page), have links edit , password reset. here code:

   <% if current_user.admin? || current_user == @user %>    <%= link_to "edit", edit_user_path(@user) %> |     <%= link_to "password reset", user_passreset_path(@user)%>    <% end %> 

when click on "password reset" link, follow error:
activerecord::recordnotfound in userscontroller#show
couldn't find user 'id'=passreset

the source users controller set_user function:

def set_user   @user = user.find(params[:id]) end 

the route new function looks this:

resources :users resources :articles 'passreset' end 

rake routes shows line:

 user_passreset    /users/:user_id/passreset(.:format)                 users#passreset 

i've explicitly declared route (get 'users/passreset'), doesn't make difference.

why looking id of 'passreset'? don't it.

i don't think matters, passrest function users controller:

 def passreset  respond_to |format|   if @user.update(user_params)     format.html { redirect_to @user, notice: 'password      updated.' }     format.json { render :show, status: :ok, location: @user }   else     format.html { render :edit }     format.json { render json: @user.errors, status:  :unprocessable_entity }   end end end 

if @ route output , looking user_id part of nested route

user_passreset    /users/:user_id/passreset(.:format)   

if make route on member, should match based on :id again.

resources :users   resources :articles   member      'passreset'   end end  

Comments

Popular posts from this blog

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -