Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6326373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:04:40+00:00 2026-05-24T17:04:40+00:00

In a Rails-3.0.10 app, I’ve got a route like this: match / => GithubTrends

  • 0

In a Rails-3.0.10 app, I’ve got a route like this:

  match "/" => GithubTrends

which point a sinatra app in lib/github_trends.rb :

$:.unshift File.dirname(__FILE__)

class GithubTrends < Sinatra::Base

disable :run
set :root, File.dirname(__FILE__) + '/../'
set :cache_enabled, true # production

LANGUAGES = ['ActionScript', 'Ada', 'Arc', 'Asp', 'Assembly', 'Boo', 'C', 'C#', 'C++', 'Clojure', 'CoffeeScript', 'ColdFusion', 'Common Lisp', 'D', 'Delphi', 'Dubi', 'Eiffel', 'Emacs Lisp', 'Erlang', 'F#', 'Factor', 'FORTRAN', 'Go', 'Groovy', 'Haskell', 'HaXe', 'Io', 'Java', 'JavaScript', 'Lua', 'Max/MSP', 'Nu', 'Objective-C', 'Objective-J', 'OCaml', 'ooc', 'Perl', 'PHP', 'Pure Data', 'Python', 'R', 'Racket', 'Ruby', 'Scala', 'Scheme', 'sclang', 'Self', 'Shell', 'SmallTalk', 'SuperCollider', 'Tcl', 'Vala', 'Verilog', 'VHDL', 'VimL', 'Visual Basic', 'XQuery']

CONTEXTS = ['most_watched_today', 'most_watched_this_week', 'most_watched_this_month', 'most_watched_overall', 'most_forked_today', 'most_forked_this_week', 'most_forked_this_month', 'most_forked_overall']

get "/" do
  @languages = LANGUAGES
  @contexts = CONTEXTS
  haml(:index)
end

… but it doesn’t work, getting the following errors:

lsoave@ubuntu:~/rails/github/gitwatcher$ rails s -p3001
=> Booting Mongrel
=> Rails 3.0.10 application starting in development on http://0.0.0.0:3001
=> Call with -d to detach
=> Ctrl-C to shutdown server
MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps.
MONGODB admin['$cmd'].find({:ismaster=>1})
MONGODB admin['$cmd'].find({:ismaster=>1})
Exiting
/home/lsoave/rails/github/gitwatcher/config/routes.rb:3:in `block in <top (required)>': uninitialized constant GithubTrends (NameError)
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.10/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.10/lib/action_dispatch/routing/route_set.rb:233:in `draw'
    from /home/lsoave/rails/github/gitwatcher/config/routes.rb:1:in `<top (required)>'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:127:in `block in reload_routes!'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:127:in `each'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:127:in `reload_routes!'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:120:in `block in routes_reloader'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.10/lib/active_support/file_update_checker.rb:32:in `call'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/activesupport-3.0.10/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application/finisher.rb:51:in `block (2 levels) in <module:Finisher>'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application/finisher.rb:52:in `call'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application/finisher.rb:52:in `block in <module:Finisher>'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/initializable.rb:25:in `instance_exec'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/initializable.rb:25:in `run'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/initializable.rb:49:in `each'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/initializable.rb:49:in `run_initializers'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:134:in `initialize!'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:77:in `method_missing'
    from /home/lsoave/rails/github/gitwatcher/config/environment.rb:5:in `<top (required)>'
    from /home/lsoave/rails/github/gitwatcher/config.ru:3:in `block in <main>'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
    from /home/lsoave/rails/github/gitwatcher/config.ru:1:in `new'
    from /home/lsoave/rails/github/gitwatcher/config.ru:1:in `<main>'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/server.rb:162:in `app'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/server.rb:204:in `start'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/commands/server.rb:65:in `start'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/commands.rb:30:in `block in <top (required)>'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/commands.rb:27:in `tap'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
lsoave@ubuntu:~/rails/github/gitwatcher$

The fist line say “uninitialized constant GithubTrends (NameError)” …

UPDATE

I added the following to config/application.rb:

config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]

… but now I get :

Exiting
/home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:168:in `call': undefined method `reverse_merge!' for Sinatra::Application:Class (NoMethodError)
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:77:in `method_missing'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:73:in `block in to_app'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:73:in `each'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:73:in `inject'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:73:in `to_app'
    from /home/lsoave/rails/github/gitwatcher/config.ru:1:in `<main>'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/server.rb:162:in `app'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/rack-1.2.3/lib/rack/server.rb:204:in `start'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/commands/server.rb:65:in `start'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/commands.rb:30:in `block in <top (required)>'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/commands.rb:27:in `tap'
    from /home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

UPDATE-2:

running sinatra manually, start the server but get, ‘may be’, a routing error :

lsoave@ubuntu:~/rails/github/gitwatcher$ ruby lib/github_trends.rb
== Sinatra/1.2.6 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.2.11 codename Bat-Shit Crazy)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop
^T127.0.0.1 - - [19/Aug/2011 00:18:50] "GET / HTTP/1.1" 404 436 0.0011
127.0.0.1 - - [19/Aug/2011 00:18:50] "GET /__sinatra__/404.png HTTP/1.1" 200 23305 0.0327
127.0.0.1 - - [19/Aug/2011 00:18:51] "GET /favicon.ico HTTP/1.1" 404 447 0.0010

UPDATE (the last & working update):

config.autoload_paths += %W(#{config.root}/lib) 

was not enough in my case. I still got the following error :

/home/lsoave/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.10/lib/rails/application.rb:168:in `call': undefined method `reverse_merge!' for Sinatra::Application:Class (NoMethodError)

… also running ruby lib/github_trends.rb (manually ran in isolation as suggested by hrickards ), worked fine after some ‘triming’, but got the previous error when running via “rails s”.

But it was enough adding require File.dirname( __FILE__ ) + "/lib/github_trends" to config.ru rails file, to have everithing working fine !

This was on suggestion by Ryan Bigg, see comment n.10:

… the problem is that Luca is not requiring the file that defines that
constant before he attempts to reference it

… even if, I don’t fully understand way config.autoload_paths alone, didn’t work …

I’d like to thanks for the troubleshooting & config.autoload_paths suggested by hrickards see the comments.

Thanks
luca

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:04:41+00:00Added an answer on May 24, 2026 at 5:04 pm

    As per the comments above, we managed to isolate the issue down to a bug in the actual Sinatra app.

    My advice would be to start with the hello world app from the Sinatra site, and slowly add in pieces of code from your app until you find the break.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Rails app has some pages which are SSL-required and others which are SSL-optional.
On my rails app I have a list of items (like a task list)
My Rails app is generating this error whenever validation aren't met: undefined method `model_name'
For a Rails app, I would like to overload or modify Kernel::load such that
in my Rails app have this routes.rb: devise_for :admin namespace :admin do root :to
Once my Rails 3 app is loaded, a user can click an item which
A rails app I am developing currently has about 35 migrations up to this
My Rails app creates a handful of very simple landing pages and I'd like
My rails app has a simple model Links which tracks all the Urls associated
I currently have a Rails app in which users of different ranks can upload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.