SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple app - problems w/ routes

    Hello,
    I'm trying to get the backbone of a rails project up and running on localhost and also on a rails playground hosted site.

    On localhost the app runs great and I can call my say/hello w/ either: http://localhost:3000/controller/say/hello or http://localhost:3000/say/hello,

    but when I try this on my rails playground site I get this when I call the say/hello like this: http://erichermann.com/say/hello:

    ActionView::MissingTemplate (Missing template say/hello.html.erb in view path /home/c73mr0ck/railsapp/app/views):
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_view/template.rb:85:in `raise_missing_template_exception'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_view/template.rb:78:in `set_extension_and_file_name'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_view/template.rb:15:in `initialize'

    And I get this when I call the say/hello like this: http://erichermann.com/controller/say/hello:

    ActionController::RoutingError (No route matches "/controller/say/hello" with {:method=>:get}):
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/recognition_optimisation.rb:67:in `recognize_path'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:384:in `recognize'
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:148:in `handle_request'
    ect.


    My controller code looks like this

    Code:
    class SayController < ApplicationController
      def hello
      end
    end
    And my routes.rb code looks like this:
    Code:
    ActionController::Routing::Routes.draw do |map|
      map.connect ':controller/:action/:id'
      map.connect ':controller/:action/:id.:format'
    end
    One thing that could be causing a big problem is that on localhost, my rails version is: Rails 1.2.6

    and on the Rails Playground hosting the version is: Rails 2.1.1

    Any ideas how I can get this to work in both places?

    Thanks,
    Clem

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    My best advice is to develop in the same version you're deploying. If you can't do that, maybe you can "freeze" to the old version to force the online app to run with old files?

  3. #3
    SitePoint Wizard xyuri's Avatar
    Join Date
    Jul 2002
    Location
    Brisbane
    Posts
    1,487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Didnt the template files change their extension a few versions ago or something? Maybe it is looking for a template with the old extension.

    Sorry to be so vague, but I only remember reading something about this a few days ago Hope it is of some use

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    AFAIK, ver 2 still works OK with ".rhtml" files, but ver 3 will not.

    To summarize the problem:

    On "localhost" Rails ver 1.2.6
    http://localhost:3000/controller/say/hello
    http://localhost:3000/say/hello

    Both work, but:

    On "erichermann.com" Rails ver 2.1.1
    http://erichermann.com/controller/say/hello
    http://erichermann.com/say/hello

    There are errors. This "missing template" error suggests a missing file, which could be solved by checking it's spelling and existence. But I have a feeling the actual problem has to do with the routing of actionpack as suggested by the "no route matches" error.

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's weird because the first link (http://erichermann.com/controller/say/hello) tries to find:

    say/hello.html.erb

    and my question is what is an .erb filetype?


    Also, I definitely have a routing problem but I thought the most basic routes would cover these standard calls:

    map.connect ':controller/:action/:id'
    map.connect ':controller/:action/:id.:format'

    I also tried to make direct route to the say controller like this:

    map.connect 'say', :controller => 'say', :action => 'hello'

    but really, I shouldn't have to do this.

    Strange

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,255
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    The ".erb" files are "view" files. It is the new extension used in place of ".rhtml"
    AFAIK, there are some parsing differences, but Rails 2 provides backwards compatability, while Rails 3 will not.

    Just a thought, is the only difference between "localhost" and "erichermann.com" the Rails version? You aren't testing localhost in development and erichermann in production are you?

  7. #7
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm - I am definately testing in development locally and on production on the erichermann site. How do I switch between the 2?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •