• Rails application development tips

    Since we don't want to output the value returned by @articles.each, we've wrapped this code in <% %>. But since we want to output the value returned by article.title (for each article), we've wrapped this code in <%= %>.

     

    The final result can be seen by visiting http://localhost:3000. (Remember, the bin/rails server must be running!) Here's what happens:

     

    The browser will make a request: GET http://localhost:3000.

    Our Rails application will receive this request.

    The Rails router will bind the root route to the index action in the ArticlesController.

    The index action uses the Article model to retrieve all articles from the database.

    Rails will automatically render the app/views/articles/index.html.erb view.

    The ERB code is calculated in view for HTML output.

    The server will send a response containing HTML back to the browser.

    We've put all the pieces of MVC together and now we have our first controller action! Next, we move on to the second action.


    Tags Tags : , ,