Some routes stopped working

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!

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?

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 :wink:

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)
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.

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.”

Problem solved, I’m just an idiot