I finished the Ruby On Rails course so I tried to create my own rails app on my macbook. I went to the terminal and created a route, view, and controller. When I went to add html code to the .html.erb file under pages, the file did not show up. I am using Ruby 2.3.1, and Rails 4.2.1. Am I doing something wrong? Is it my macbook? Does Codecademy use a different version of Rails? Help?!!
If you're getting the "Welcome aboard" page then rails is probably working fine on your system, perhaps you've probably got the route wrong
Have you had a look at what the server says it's doing with the GET request?
Hey, ionatan. Thanks for responding. I am getting the "Welcome aboard" page. I don't think that I am doing something wrong though. When I start the rails new command, it is supposed to generate a .html.erb file under pages. It's not. In fact, its not even generating a pages folder under views.
Maybe it's not supposed to after all.
But you could create a controller with that name.
Here, try this:
$ # create the rails app $ rails new MyApp $ # change directory into the created app $ cd MyApp $ # generate a controller Pages with a view index $ rails generate controller Pages index $ # edit the html $ echo hello world > app/views/pages/index.html.erb $ # add a line in routes.rb to route / to the view we created $ sed "3i\ root 'pages#index'" config/routes.rb $ rails server $ # visit http://localhost:3000
You might want to edit files with a text editor instead of with echo and sed. I'm just squeezing it in there.
Thanks, that worked!