2016-05-09 26 views
4

我創建了一個新的遷移,它看起來像這樣的:修復`缺少冷凍字符串字面comment`問題

class AddCommentsToUsers < ActiveRecord::Migration 
    def change 
    add_column :users, :comments, :text 
    end 
end 
與代碼氣候

現在我警告過一個問題: Missing frozen string literal comment.

我試着修復它像這樣:

# frozen_string_literal: true 
class AddCommentsToUsers < ActiveRecord::Migration 
    def change 
    add_column :users, :comments, :text 
    end 
end 

但我仍然有同樣的問題。我該如何解決它?謝謝。

+2

看起來正確的給我。您是否使用Code Climate CLI或rubocop在當地進行過調查? –

回答

6

我遇到了同樣的問題。 Rubocop之前工作正常,但突然開始動作。我閱讀了他們在github上的配置選項,並看到了與您的代碼混淆的特定屬性。 該物業可以在這裏找到:FrozenStringLiteral

爲了解決這個問題,你只需要添加到您的rubocop.yml文件

Style/FrozenStringLiteralComment: 
    Enabled: false