I am new to Rails, so please forgive me if this is obvious.
I am doing a lot of experimenting, creating to applications, testing features, etc. It got my first scaffolded app running great, but I wanted to create a second app to test a different feature.
I backed up a folder level on my computer, ran $ rails new taskmaster
(a test to-do list app). I ran the scaffolding for the Task
model, fired up the server via $ rails server
, and attempted to load http://localhost:3000
.
But I got a routing error, saying it couldn't find the "members"
route. But members
was from my first Rails app! I thought by firing off $ rails server
in the taskmaster
directory, it would startup the server for that application.
How do I tell the Rails server which application to serve up?
UPDATE
I just discovered that if I:
$ rails server
in the application's root directoryhttp://localhost:3000
It still attempts to go for the members
route, the one that no longer exists because I rolled back via git.
I'm guessing this means something in my /usr/local/
area, relating to my Ruby and Rails initial installs, is mainatining this info (my apps are setup in my Documents folder in my home dir).
I thought that Rails apps were essentially self contained apps inside the directory - you just needed a working Ruby install to get them going. Does the Rails server sit inside each app directory, or is the some overarching Rails server that accommodates all apps?
You can run multiple instances of webrick server on localhost by assigning a different port number as:
rails s -p 3007
But sometimes it may not work.
I have a tip for you.You can try using this along with other options provided by webrick. Just try with providing any number as PID using -P
:
rails s -p 3007 -P 42342
I suspect the old server was still running and the new server failed to start. Try killing it first and then start it your new app.
Alternatively, you could start the new server on a different port by using the -p
switch (e.g. rails server -p 3001
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With