Topic: localhost

Hello, I have a problem. So here's the story:

So originally I had a problem getting localhost:3000 to work. I fixed that but when I deleted the old index for that, and made a new page
for my app, it stopped working in a completely different way. It returns an error every time I try to get into localhost:3000. The type of error
is actually a routing error. I don't know what that is but apparently, it has to do with the file that my app is routed from. Or it wouldn't happen when I got
rid of the old index. Help?

Re: localhost

You did ok by removing the index.html file from your Public directory. Thats the first step in creating your own web app after installing Rails. You now need to go and create or generate a page and then configure your routes.rb to your new page.

Next step: Command Line$> rails generate controller newpage (hit return or enter)

This will create a controller for the new page. Open your text editor and create a page called newpage.html.erb in the newpage directory. Put whatever html in there you want, for example "<H1>Hello World!</H1> save the file.

The open up the newpage controller file inside the controllers directory and before the end statement add a few lines. Then on one of those lines type:

def newpage

And then save that file. Now go to your routes.rb file and open it in your text editor. Just about everything inside there should be commented out. Scroll down to the root example.

#root :to => 'welcome#index'

You are looking for the line above. You can either copy and paste it above without the #(comment) or just uncomment it. But be sure to read the text on that page at some point to familiarize yourself with the routes file.

Then change it to:

root :to => 'newpage#newpage'

And save it. Then check your browser again going to the localhost:3000 url and it should pull up the "Hello World!" page you created in the newpage directory. If not then just follow the error and fix the problems by googling them.

Re: localhost

Oh just so you know you could have called the def anything you wanted for example index. But then you'd need to make the file inside the newpage directory have the url of index.html.erb and in the route file you would use 'newpage#index' instead. With that you should be on your way to making static pages at the very least with the ability to use embedded ruby within them.