Rails annotations

Comments for Rails view pages and controllers can be added in different ways

For comments on view pages, you can use HTML comments inside HTML or ERB tags, like this:

<!-- 这是一个视图页面的注释 -->
<div class="container">
  ...
</div>

You can also use Ruby annotations inside ERB tags, like so:

<%# 这是一个视图页面的注释 %>
<div class="container">
  ...
</div>

For controller comments, you can use Ruby's single-line comments or multi-line comments to add, as follows:

# 这是一个控制器的注释

class UsersController < ApplicationController
  ...
end
=begin
这是一个控制器的注释
多行注释
=end

class UsersController < ApplicationController
  ...
end

Please note that these annotations are only for recording and understanding code between developers, they will not be executed at runtime.

Guess you like

Origin blog.csdn.net/Toml_/article/details/131653449