newbie - WEbrick, config/routes.rb and multiple instances

Discussion in 'Ruby' started by Iain Barnett, Jun 27, 2010.

  1. Iain Barnett

    Iain Barnett Guest

    Hi,

    I've been going through the book Head First RoR, and in it I've been =
    asked to make a tickets app, and then an events app.

    So:

    $ rails tickets
    $ cd tickets
    $ ruby script/generate scaffold ticket name:string seat_id_seq:string =
    address:text price_paid:decimal email_address:string
    $ rake db:migrate
    $ ruby script/server

    Then I can browse to http://localhost:3000/tickets

    $ cd ..
    $ rails events
    $ cd events
    $ ruby script/generate scaffold event artist:string description:text =
    price_low:decimal price_high:decimal event_date:date
    $ rake db:migrate

    at this point if I browse to http://localhost:3000/tickets I can still =
    see it, but if I go to http://localhost:3000/events then I get the =
    following message:

    Routing Error


    No route matches "/events" with {:method=3D>:get}

    If I stop the WEbrick server and start it from within the events dir I =
    get the same error but for tickets. =46rom what I've been able to find =
    out, the server is reading from config/routes.rb, but obviously it will =
    take this from the dir that I started WEbrick from.


    Is there a way I can get both apps to work at the same time, or do I =
    have to start 2 separate instances of the server? Have I missed =
    something obvious??

    Any help or input is much appreciated. I'm running OSX 10.6 with Ruby =
    1.9.1 and Rails 2.3.8

    Iain=
     
    Iain Barnett, Jun 27, 2010
    #1
    1. Advertising

  2. Iain Barnett

    Josh Cheek Guest

    [Note: parts of this message were removed to make it a legal post.]

    On Sun, Jun 27, 2010 at 8:01 AM, Iain Barnett <> wrote:

    > Hi,
    >
    > I've been going through the book Head First RoR, and in it I've been asked
    > to make a tickets app, and then an events app.
    >
    > So:
    >
    > $ rails tickets
    > $ cd tickets
    > $ ruby script/generate scaffold ticket name:string seat_id_seq:string
    > address:text price_paid:decimal email_address:string
    > $ rake db:migrate
    > $ ruby script/server
    >
    > Then I can browse to http://localhost:3000/tickets
    >
    > $ cd ..
    > $ rails events
    > $ cd events
    > $ ruby script/generate scaffold event artist:string description:text
    > price_low:decimal price_high:decimal event_date:date
    > $ rake db:migrate
    >
    > at this point if I browse to http://localhost:3000/tickets I can still see
    > it, but if I go to http://localhost:3000/events then I get the following
    > message:
    >
    > Routing Error
    >
    >
    > No route matches "/events" with {:method=>:get}
    >
    > If I stop the WEbrick server and start it from within the events dir I get
    > the same error but for tickets. From what I've been able to find out, the
    > server is reading from config/routes.rb, but obviously it will take this
    > from the dir that I started WEbrick from.
    >
    >
    > Is there a way I can get both apps to work at the same time, or do I have
    > to start 2 separate instances of the server? Have I missed something
    > obvious??
    >
    > Any help or input is much appreciated. I'm running OSX 10.6 with Ruby
    > 1.9.1 and Rails 2.3.8
    >
    > Iain



    When you do script/server, you can pass a port to run the application on.

    In one terminal: $ cd tickets && script/server
    In another terminal $ cd events && script/server -p 3001

    Then in your browser, you can see tickets at localhost:3000/tickets
    And you can see events at localhost:3001/events

    By the way, check and make sure you read it correctly, because this is
    almost certainly not what you want. Probably they wanted you to make two
    different scaffolds, not two different applications.
     
    Josh Cheek, Jun 27, 2010
    #2
    1. Advertising

  3. On Sun, Jun 27, 2010 at 6:01 AM, Iain Barnett <> wrote:

    > I've been going through the book Head First RoR, and in it I've been asked to make a tickets app, and then an events app.


    > Is there a way I can get both apps to work at the same time, or do I have to start 2 separate instances of the server? Have I missed something obvious??


    Yes to all of the above. You have 2 separate apps, so yes, you have
    to start 2 servers to handle them.

    You can run them simultaneously by configuring one to use a different
    port.

    --
    Hassan Schroeder ------------------------
    twitter: @hassan
     
    Hassan Schroeder, Jun 27, 2010
    #3
  4. Iain Barnett

    Josh Cheek Guest

    [Note: parts of this message were removed to make it a legal post.]

    On Sun, Jun 27, 2010 at 8:47 AM, Josh Cheek <> wrote:

    > On Sun, Jun 27, 2010 at 8:01 AM, Iain Barnett <> wrote:
    >
    >> Hi,
    >>
    >> I've been going through the book Head First RoR, and in it I've been asked
    >> to make a tickets app, and then an events app.
    >>
    >> So:
    >>
    >> $ rails tickets
    >> $ cd tickets
    >> $ ruby script/generate scaffold ticket name:string seat_id_seq:string
    >> address:text price_paid:decimal email_address:string
    >> $ rake db:migrate
    >> $ ruby script/server
    >>
    >> Then I can browse to http://localhost:3000/tickets
    >>
    >> $ cd ..
    >> $ rails events
    >> $ cd events
    >> $ ruby script/generate scaffold event artist:string description:text
    >> price_low:decimal price_high:decimal event_date:date
    >> $ rake db:migrate
    >>
    >> at this point if I browse to http://localhost:3000/tickets I can still
    >> see it, but if I go to http://localhost:3000/events then I get the
    >> following message:
    >>
    >> Routing Error
    >>
    >>
    >> No route matches "/events" with {:method=>:get}
    >>
    >> If I stop the WEbrick server and start it from within the events dir I get
    >> the same error but for tickets. From what I've been able to find out, the
    >> server is reading from config/routes.rb, but obviously it will take this
    >> from the dir that I started WEbrick from.
    >>
    >>
    >> Is there a way I can get both apps to work at the same time, or do I have
    >> to start 2 separate instances of the server? Have I missed something
    >> obvious??
    >>
    >> Any help or input is much appreciated. I'm running OSX 10.6 with Ruby
    >> 1.9.1 and Rails 2.3.8
    >>
    >> Iain

    >
    >
    > When you do script/server, you can pass a port to run the application on.
    >
    > In one terminal: $ cd tickets && script/server
    > In another terminal $ cd events && script/server -p 3001
    >
    > Then in your browser, you can see tickets at localhost:3000/tickets
    > And you can see events at localhost:3001/events
    >
    > By the way, check and make sure you read it correctly, because this is
    > almost certainly not what you want. Probably they wanted you to make two
    > different scaffolds, not two different applications.
    >



    Oh, and this is a mailing list for the Ruby programming language, not the
    Ruby on Rails web framework.
    You'll probably have more luck at
    http://groups.google.com/group/rubyonrails-talk
     
    Josh Cheek, Jun 27, 2010
    #4
  5. Iain Barnett

    Iain Barnett Guest

    On 27 Jun 2010, at 14:47, Hassan Schroeder wrote:

    >=20
    > Yes to all of the above. You have 2 separate apps, so yes, you have
    > to start 2 servers to handle them.
    >=20
    > You can run them simultaneously by configuring one to use a different
    > port.
    >=20


    On 27 Jun 2010, at 14:47, Josh Cheek wrote:

    >=20
    > When you do script/server, you can pass a port to run the application =

    on.
    >=20
    > In one terminal: $ cd tickets && script/server
    > In another terminal $ cd events && script/server -p 3001
    >=20
    > Then in your browser, you can see tickets at localhost:3000/tickets
    > And you can see events at localhost:3001/events
    >=20
    > By the way, check and make sure you read it correctly, because this is
    > almost certainly not what you want. Probably they wanted you to make =

    two
    > different scaffolds, not two different applications.



    Thanks for all the help. I had a look and the url's both use the same =
    port and nothing is mentioned about using other ports. I checked the =
    book's site for errata but didn't see anything.

    On 27 Jun 2010, at 14:49, Josh Cheek wrote:

    > On Sun, Jun 27, 2010 at 8:47 AM, Josh Cheek <> =

    wrote:
    >=20
    >=20
    > Oh, and this is a mailing list for the Ruby programming language, not =

    the
    > Ruby on Rails web framework.
    > You'll probably have more luck at
    > http://groups.google.com/group/rubyonrails-talk


    Ok, thanks very much for pointing that out.

    Iain=
     
    Iain Barnett, Jun 27, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniele
    Replies:
    8
    Views:
    9,257
    Victor Bazarov
    Aug 3, 2004
  2. shapper

    ASP.NET MVC Routes

    shapper, Jul 29, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    571
    Cowboy \(Gregory A. Beamer\)
    Jul 29, 2008
  3. Seth Rasmussen
    Replies:
    3
    Views:
    201
    Seth Rasmussen
    Sep 17, 2005
  4. Nimisha Mohandas

    Routes.rb

    Nimisha Mohandas, Jul 21, 2006, in forum: Ruby
    Replies:
    0
    Views:
    132
    Nimisha Mohandas
    Jul 21, 2006
  5. Aaron Smith

    WEBrick::Daemon and WEBrick

    Aaron Smith, Mar 9, 2007, in forum: Ruby
    Replies:
    2
    Views:
    317
    Aaron Smith
    Mar 18, 2007
Loading...

Share This Page