230 Matching Annotations
  1. Jul 2015
    1. every Rails model can be initialized with its respective attributes, which are automatically mapped to the respective database columns
    2. command will apply to the database defined in the development section of your config/database.yml file
    3. Migrations are Ruby classes that are designed to make it simple to create and modify database tables. Rails uses rake commands to run migrations, and it's possible to undo a migration after it's been applied to your database.
    4. Rails responded by creating a bunch of files. For now, we're only interested in app/models/article.rb and db/migrate/20140120191729_create_articles.rb
    5. a text attribute of type text.
    6. a title attribute of type string
    7. we want a Article model,
    8. database tables use a plural name.
    9. Models in Rails use a singular name
    10. When a form is submitted, the fields of the form are sent to Rails as parameters.
    11. This is associated with the create action of the current controller
    12. the form will (by default) send a POST request
    13. The articles_path helper tells Rails to point the form to the URI Pattern associated with the articles prefix
    14. you will see that the action attribute for the form is pointing at /articles/new. This is a problem because this route goes to the very page that you're on right at the moment, and that route should only be used to display the form for a new article.
    15. When you call form_for, you pass it an identifying object for this form.
    16. handler must be one of erb, builder or coffee.
    17. format for this template can only be html
    18. second extension is the handler that will be used.
    19. the first extension is the format of the template
    20. app/views/articles/new.html.erb.
    21. The final part of this message tells us where Rails has looked for the templates.
    22. :handlers, is telling us what template handlers could be used to render our template. :erb is most commonly used for HTML templates, :builder is used for XML templates, and :coffee uses CoffeeScript to build JavaScript templates.
    23. :formats specifies the format of template to be served in response. The default format is :html, and so Rails is looking for an HTML template.
    24. The first part identifies what template is missing
    25. A controller is simply a class that is defined to inherit from ApplicationController. It's inside this class that you'll define methods that will become the actions for this controller. These actions will perform CRUD operations on the articles within our system.
    26. resources :articles

      do not omit "s"! when just type " resource :articles " then, :id is not shown in the"rake routes"

    27. Rails provides a resources method which can be used to declare a standard REST resource.
    28. A resource is the term used for a collection of similar objects, such as articles, people or animals. You can create, read, update and destroy items for a resource and these operations are referred to as CRUD operations.
    29. A view's purpose is to display this information in a human readable format. An important distinction to make is that it is the controller, not the view, where information is collected.
    30. A controller's purpose is to receive specific requests for the application. Routing decides which controller receives which requests. Often, there is more than one route to each controller, and different routes can be served by different actions. Each action's purpose is to collect information to provide it to a view.