Amr*_*ngh 2 ruby ruby-on-rails
我试图在Rails 5控制器中评论多行,我搜索了网络并找到了以下解决方案:"= begin"
=begin (Multiple lines)
respond_to do |format|
if @person.update_attributes(params[:person])
flash[:notice] = 'Person was successfully updated.'
format.html { redirect_to(@person) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @person.errors, :status => :unprocessable_entity }
end
end
=end
Run Code Online (Sandbox Code Playgroud)
但它给出了这个错误:
语法错误,意外'='=开始
我正在使用Rails 5.0.
Ruby多行注释仅在行的开头和=begin(同样适用于=end)之间没有空格时才起作用.确保该行以=begin:
这有效:
=begin
foo
bar
=end
Run Code Online (Sandbox Code Playgroud)
这不起作用:
=begin
foo
bar
=end
Run Code Online (Sandbox Code Playgroud)