Search code examples
ruby-on-railsrubymine

Do these remarks in a generated rails scaffold do anything?


When I generate a scaffold in rails, I noticed that the methods are prefaced with # remarks. I haven't been able to find any documentation as to if they actually do anything of if they are similar to what looks like remarks in application.js that look like remarks but are really code.

For example:

  # POST /attachments
  # POST /attachments.json
  def create

and

  # GET /attachments/1
  # GET /attachments/1.json
  def show
  end

I am using rubymine as my editor.


Solution

  • No, they don't do any magic behind the scenes. They are just comments to help you out.

    By default, scaffolding will direct POST requests to create(), and GET of a particular resource (e.g. /resources/<id>) to show(). These associations are defined in your routes, and scaffolding applies this convention. You're free to change them in your routes if you wish.