# Some routes stopped working

**URL:** <https://www.ruby-forum.com/t/some-routes-stopped-working/157523>\
**Category:** Rails\
**Created:** [January 12, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/some-routes-stopped-working/157523 "2009-01-12T16:27:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@bryan](https://www.ruby-forum.com/u/bryan)\
**Post date:** [January 12, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/some-routes-stopped-working/157523/1 "2009-01-12T16:27:25Z")

</div>

I’m relatively new to Rails, so the solution to this might be more  
trivial than I think However, I am working on an app, and everything  
was working fine until just recently. The problem is I’m not sure  
_when_ I might have screwed up, hence my not knowing where the problem  
lies.

I’m running Rails 2.1.2

All routes in routes.rb were working fine, but for some reason, a few  
stopped working. Here is my routes code:

* * *

ActionController::Routing::Routes.draw do |map|

# See how all your routes lay out with “rake routes”

map.connect ‘’, :controller =\> ‘site’

map.resources :questions, :has\_many =\> [:replies], :collection =\>  
{:search =\> :get}  
map.resources :passwords  
map.resources :users, :has\_one =\> [:password], :has\_many =\>  
[:replies]  
map.resource :session  
map.resources :beta\_invitations

map.new\_contact ‘/contact/new’, :controller =\> ‘contact’, :action =\>  
‘new’, :conditions =\> { :method =\> :get }  
map.contact ‘/contact’, :controller =\> ‘contact’, :action =\>  
‘new’, :conditions =\> { :method =\> :get }  
map.contact ‘/contact’, :controller =\> ‘contact’, :action =\>  
‘create’, :conditions =\> { :method =\> :post }

map.home ‘:action’, :controller =\> ‘site’  
map.signup ‘/signup’, :controller =\> ‘users’, :action =\> ‘new’  
map.signin ‘/signin’, :controller =\> ‘sessions’, :action =\>  
‘create’  
map.signout ‘/signout’, :controller =\> ‘sessions’, :action =\>  
‘destroy’  
map.questions ‘/questions’, :controller =\> ‘site’, :action =\>  
‘questions’  
map.privacy ‘/privacy’, :controller =\> ‘site’, :action =\>  
‘privacy\_policy’  
map.terms ‘/terms’, :controller =\> ‘site’, :action =\>  
‘terms\_of\_service’  
map.about ‘/about’, :controller =\> ‘site’, :action =\> ‘about’  
map.graphs ‘/graphs’, :controller =\> ‘graphs’, :action =\> ‘stats’

# Install the default routes as the lowest priority.

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’

# Custom handle 404/500 errors

map.notfound ‘\*args’, :controller =\> ‘site’, :action =\> ‘custom404’

## end

Just recently, the signup, signout, privacy, and terms paths stopped  
working. The controllers and models seem to be as they were before  
they stopped working and the files names haven’t changed, so I’m not  
sure where to fix the problem.

If more is needed to assess the problem, please let me know. Thanks!

---

<div class="post-metadata">

**Author:** ![bryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@bryan](https://www.ruby-forum.com/u/bryan)\
**Post date:** [January 12, 2009, 4:45pm UTC](https://www.ruby-forum.com/t/some-routes-stopped-working/157523/2 "2009-01-12T16:45:50Z")

</div>

> All routes in routes.rb were working fine, but for some reason, a few  
> stopped working.

do you have any error-messages? what did you call? what do you get?

---

<div class="post-metadata">

**Author:** ![bryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@bryan](https://www.ruby-forum.com/u/bryan)\
**Post date:** [January 12, 2009, 10:26pm UTC](https://www.ruby-forum.com/t/some-routes-stopped-working/157523/3 "2009-01-12T22:26:19Z")

</div>

Well I’m a RoR newbie but what I see is the following:

1. Error Message:  
somebody called /site/signup (right?)  
but your controller (site) doesn’t have such an action. Here your  
would have to define one.  
The actions you have definied in your site controller are

- new
- show
- update
- create
- edit

1. Routes  
But you route signup the following way  
map.signup ‘/signup’, :controller =\> ‘users’, :action =\> ‘new’

It seems to me that there is some inconsistency.

I hope I was some help 😉

---

<div class="post-metadata">

**Author:** ![bryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@bryan](https://www.ruby-forum.com/u/bryan)\
**Post date:** [January 12, 2009, 9:52pm UTC](https://www.ruby-forum.com/t/some-routes-stopped-working/157523/4 "2009-01-12T21:52:38Z")

</div>

Thanks for the reply. This is what’s in the log:

LOG

Processing SiteController#signup (for 127.0.0.1 at 2009-01-12  
15:41:17) [GET]  
Session ID:  
BAh7BzoMY3NyZl9pZCIlYjUzYTM5Yjk4ZmY4ZGQwMzM0YmFkZWIzYzM1MTc2  
MjMiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh  
c2h7AAY6CkB1c2VkewA=–9a211b8e03c1b16513a196e3fb3f3c468f12bca9  
Parameters: {“action”=\>“signup”, “controller”=\>“site”}

ActionController::UnknownAction (No action responded to signup):  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/filters.rb:579:in `call_filters' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/ action_controller/filters.rb:572:in `perform\_action\_without\_benchmark’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/benchmarking.rb:68:in  
`perform_action_without_rescue' C:/INSTAN~1/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/benchmarking.rb:68:in  
`perform_action_without_rescue' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/ action_controller/rescue.rb:201:in `perform\_action\_without\_caching’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/caching/sql\_cache.rb:13:in `perform_action' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/ active_record/connection_adapters/abstract/query_cache.rb:33:in `cache’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/  
active\_record/query\_cache.rb:8:in `cache' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/ action_controller/caching/sql_cache.rb:12:in `perform\_action’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/base.rb:529:in `send' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/ action_controller/base.rb:529:in `process\_without\_filters’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/filters.rb:568:in  
`process_without_session_management_support' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/ action_controller/session_management.rb:130:in `process’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/base.rb:389:in `process' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/ action_controller/dispatcher.rb:149:in `handle\_request’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/dispatcher.rb:107:in `dispatch' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/ action_controller/dispatcher.rb:104:in `synchronize’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/dispatcher.rb:104:in `dispatch' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/ action_controller/dispatcher.rb:120:in `dispatch\_cgi’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/dispatcher.rb:35:in `dispatch' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/../lib/mongrel/rails.rb:76:in `process’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel/rails.rb:74:in `synchronize' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/../lib/mongrel/rails.rb:74:in `process’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel.rb:159:in `process_client' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/../lib/mongrel.rb:158:in `each’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel.rb:158:in `process_client' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/../lib/mongrel.rb:285:in `run’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel.rb:285:in `initialize' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/../lib/mongrel.rb:285:in `new’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel.rb:285:in `run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/../lib/mongrel.rb:268:in `initialize’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel.rb:268:in `new' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/../lib/mongrel.rb:268:in `run’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel/configurator.rb:282:in `run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/../lib/mongrel/configurator.rb:281:in `each’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel/configurator.rb:281:in `run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/mongrel_rails:128:in `run’  
C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/  
bin/…/lib/mongrel/command.rb:212:in `run' C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/ bin/mongrel_rails:281 C:/INSTAN~1/ruby/bin/mongrel_rails:19:in `load’  
C:/INSTAN~1/ruby/bin/mongrel\_rails:19

Rendering C:/INSTAN~1/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/  
action\_controller/templates/rescues/layout.erb (not\_found)

User CONTROLLER:

class UsersController \< ApplicationController  
before\_filter :login\_from\_cookie  
before\_filter :login\_required, :only =\> [:edit, :update]

# GETs should be safe (see

[URIs, Addressability, and the use of HTTP GET and POST](http://www.w3.org/2001/tag/doc/whenToUseGet.html))  
verify :method =\> :post, :only =\> [:create], :redirect\_to =\>  
{ :controller =\> :site }  
verify :method =\> :put, :only =\> [:update], :redirect\_to =\>  
{ :controller =\> :site }

# GET /question/1

# Show user’s questions

def show  
@user = User.find\_by\_login(params[:id])

```
@questions = @user.questions.paginate(:page => params

```

[:page], :per\_page =\> 10, :conditions =\> “NOT anonymous”)

```
respond_to do |format|
  format.html # show.html.erb
end

```

end

# GET /users/new

def new  
end

# POST /users

# Signup a new user

def create  
cookies.delete :auth\_token  
# protects against session fixation attacks, wreaks havoc with  
# request forgery protection.  
# uncomment at your own risk  
# reset\_session

```
@user = User.new(params[:user])
@user.gender = params[:user][:gender].to_i
@user.birthdate = Date.new(params[:date]['birth_year'].to_i, params

```

[:date][‘birth\_month’].to\_i, params[:date][‘birth\_day’].to\_i)  
@user.country = params[:user][:country]

```
# Validate the beta invitation code.
if REQUIRE_INVITE_TO_SIGNUP
  beta_verify = Digest::MD5.hexdigest("asecretkeygoeshere"+params

```

[:user][:email])  
unless params[:invitation\_code] == beta\_verify  
flash[:notice] = “The invitation code you used is not valid.”  
render :action =\> ‘new’  
return  
end  
end

```
if verify_recaptcha(@user) && @user.save
  self.current_user = @user

  # Create the user's stats table
  stat = Stat.new(:user_id => @user.id)

  if stat.save
    # Send the new user welcome email
    UserNotifier.deliver_signup_notification(@user)

    redirect_to home_path
  else
    @user.destroy
    stat.destroy unless stat.nil?
    flash[:error] = "Your account couldn't be created"
    render :action => 'new'
  end
else
  render :action => 'new'
end

```

end

# GET /users/1/edit

# Changing username, email, or profile

def edit  
# @user = User.find(params[:id])  
@user = current\_user  
end

# PUT /users/1

# Changing username, email, or profile

def update  
# @user = User.find(params[:id])  
@user = current\_user

```
@user.attributes = params[:user]
@user.gender = params[:user][:gender].to_i
@user.birthdate = Date.new(params[:date]['birth_year'].to_i, params

```

[:date][‘birth\_month’].to\_i, params[:date][‘birth\_day’].to\_i)  
@user.country = params[:user][:country]

```
respond_to do |format|
  if @user.save
    format.html { redirect_to home_path }
  else
    format.html { render :action => 'edit' }
  end
end

```

end

end

link\_to from VIEW

\<%= link\_to image\_tag(“signup1.png”), signup\_path %\>

The others are similar. I’ve been trying out different plugins as  
well. Could that have caused this problem? Thanks.

---

<div class="post-metadata">

**Author:** ![bryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@bryan](https://www.ruby-forum.com/u/bryan)\
**Post date:** [January 12, 2009, 10:47pm UTC](https://www.ruby-forum.com/t/some-routes-stopped-working/157523/5 "2009-01-12T22:47:28Z")

</div>

This is the users controller that I included on the last post, not the  
site controller. However, the site controller is as follows:

class SiteController \< ApplicationController  
caches\_page :terms\_of\_service, :privacy\_policy, :about, :custom404  
before\_filter :login\_from\_cookie

def index  
# If a user is logged in, only show questions they haven’t  
answered

```
if logged_in?
  @questions = Question.paginate(:page => params[:page],
                                  :per_page => 20,
                                  :conditions => ["NOT EXISTS

```

(SELECT id FROM replies WHERE (replies.user\_id = ?) AND  
(replies.question\_id = questions.id))", current\_user.id],  
:include =\> :user,  
:order =\> ‘questions.created\_at  
DESC’)  
else  
@questions = Question.paginate(:page =\> params[:page],  
:per\_page =\> 15,  
:include =\> :user,  
:order =\> ‘questions.created\_at  
DESC’)  
end

```
respond_to do |format|
  format.html
end

```

end

def terms\_of\_service  
respond\_to do |format|  
format.html  
end  
end

def privacy\_policy  
respond\_to do |format|  
format.html  
end  
end

def about  
respond\_to do |format|  
format.html  
end  
end

def custom404  
render :partial =\> “custom404”, :layout =\> “application”, :status  
=\> “404”  
end  
end

On Jan 12, 4:25 pm, “Christoph J.”

---

<div class="post-metadata">

**Author:** ![bryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@bryan](https://www.ruby-forum.com/u/bryan)\
**Post date:** [January 12, 2009, 10:55pm UTC](https://www.ruby-forum.com/t/some-routes-stopped-working/157523/6 "2009-01-12T22:55:41Z")

</div>

Problem solved, I’m just an idiot
