Hello I am developing an application about registration of users, but when the user X wants to edit his information the app is taking “edit” instead of user id and shows me the following error:
ActiveRecord::RecordNotFound in UserController#show
Couldn't find User with id=edit
(I am using devise for the users), this is my home.html.rb
<body>
<div class="container">
<% if signed_in? %>
<table class="front" summary="For signed-in users">
<tr>
<td class="main">
<h1 class="micropost">What's up?</h1>
<%= link_to "edit your profile", edit_user_registration_path, :class => "signup_button round" %>
</td>
</tr>
</table>
<% else %>
<h1>Sample App</h1>
<p>
This is the home page for the <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a> sample application.
</p>
<%= link_to "Sign up now!", new_user_registration_path, :class => "signup_button round" %>
<% end %>
</div>
Here is my routes.rb (I know it should be users but if i put that as plural don`t work)
Estaciones::Application.routes.draw do
root :to => "static_pages#home"
match '/contact', :to=>'static_pages#contact'
match '/about', :to=>'static_pages#about'
get "user/:id" => "User#show"
devise_for :user
resources :user do
end
At last here is my UserController
class UserController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to user_session_path
else
redirect_to new_user_session_path
end
end
def show
@user = User.find(params[:id])
#redirect_to @user
end
end
You need to specify a user id in order for Rails to generate the correct routes.
You didn’t pass any user_id to the method in your home.html.erb.