Unknown action No action responded to show


I am new to ruby, so pardon me if i am asking something basic. I am
trying to create a simple test application where a user registers for a
account and can see his profile and edit his profile. the navigation
looks like following:

Register | Profile | Edit_Profile

Profile and Edit_profile and working fine when i use following URL’s:

Profile: http://localhost:3000/user/profile/
Edit_Profile: http://localhost:3000/user/edit_profile/1

but for some routing configuration or some reason it does not display my
registration page after i add “map.resources :user” in routes.rb file.
Register page is at following URL:

Register: http://localhost:3000/user/register

Note: Register page displays and Register functionality works fine
before i add “map.resources :user” in routes.rb, and saves the new user
account in Mysql. but in order to make Profile and Edit_profile work i
have to add “map.resources :user” in routes.rb file.

I only have 1 controller file as “user_controller.rb” which contains
following code:

class UserController < ApplicationController

def register
@title = ‘Register’
if request.post? and params[:user]
@user = User.new(params[:user])
if @user.save
flash[:notice] = ‘New Account created successfuly’

def profile
@title = ‘Profile’
@user = User.find(params[:id])

def edit_profile
@title = ‘Edit Profile’
@user = User.find(params[:id])

def update
@user = User.find(params[:id])

respond_to do |format|
  if @user.update_attributes(params[:user])
    flash[:notice] = 'User was successfully updated.'
    format.html { redirect_to :controller => 'user', :action =>

‘profile’, :id => User.find(params[:id]) }
format.xml { head :ok }
format.html { render :action => “edit_profile” }
format.xml { render :xml => @user.errors, :status =>
:unprocessable_entity }


I will be very thankful to the community for any help in this, and
continue to support the community by helping other members as i go.

Baba Bobo wrote:

sorry the correct/working URL for Profile page is

Baba Bobo wrote:

If I add the following code to my only controller file

def show
@user = User.find(params[:user])

respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }

After which when i refresh the Registeration page at
it gives me following message:

ActiveRecord::RecordNotFound in UserController#show
Couldn’t find User without an ID

Controllers are customarily named in the plural…
UsersController, as opposed to UserController.

What does a “rake routes” report to you?

rake routes >routes.lst

Then peruse that file… You’re mixing restful routes with
“non-restful” ones I think, and earlier routes are evaluated before
later in the routes.rb file, so your map.resources :user is probably
masking the later definition for “profile”.

With restful routes, you can add custom routing with:

map.resources :users, :member => {:profile => :get}
(for a single user resource, there’s a profile route and view, you
provide the controller method, and the view)


map.resource :users, :collection => {:my_index => :get}
(for a list of users, there’s a my_index route and view, again you write
the controller method and view)

or combine them (both member and collection specs).

Oh, and I think your
:id => User.find(params[:id])
is simply
:id => params[:id]
no need for the find

Ar Chron wrote:

Controllers are customarily named in the plural…
UsersController, as opposed to UserController.

What does a “rake routes” report to you?

Thanks for the prompt reply. I agree i am messing up somewhere with the
restful routing. By the time i am playing with the custom routing you
recommended, here are the things you asked.

“rake routes” report as following:

      user_index GET    /user 

{:action=>“index”, :controller=>“user”}

formatted_user_index GET /user.:format
{:action=>“index”, :controller=>“user”}

                 POST   /user 

{:action=>“create”, :controller=>“user”}

                 POST   /user.:format 

{:action=>“create”, :controller=>“user”}

        new_user GET    /user/new 

{:action=>“new”, :controller=>“user”}

formatted_new_user GET /user/new.:format
{:action=>“new”, :controller=>“user”}

       edit_user GET    /user/:id/edit 

{:action=>“edit”, :controller=>“user”}

formatted_edit_user GET /user/:id/edit.:format
{:action=>“edit”, :controller=>“user”}

            user GET    /user/:id 

{:action=>“show”, :controller=>“user”}

  formatted_user GET    /user/:id.:format 

{:action=>“show”, :controller=>“user”}

                 PUT    /user/:id 

{:action=>“update”, :controller=>“user”}

                 PUT    /user/:id.:format 

{:action=>“update”, :controller=>“user”}
DELETE /user/:id
{:action=>“destroy”, :controller=>“user”}
DELETE /user/:id.:format
{:action=>“destroy”, :controller=>“user”}

and routes.rb (withoug comments) is as following:

ActionController::Routing::Routes.draw do |map|
map.resources :user
map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’

By the way I have issue with the register page not the profile page.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs