【发布时间】:2019-08-28 01:03:14
【问题描述】:
在我的 Ruby on Rails 应用程序中进行 Rubocop 检查后,我在正确格式化以下代码时遇到了一些问题。我不断收到错误:
Rubocop:Literal[:success, JSON.parse(response.to_str)] 在 void 上下文中使用。[Lint/Void]
和
Rubocop:Literal[:unprocessable_entity, JSON.parse(response.to_str)] 在 void 上下文中使用。[Lint/Void]。
我只是不知道代码有什么问题以及如何解决它。
case response.code
when 200
[:success, JSON.parse(response.to_str)]
redirect_to root_url, notice: 'Logged in!'
when 422
[:unprocessable_entity, JSON.parse(response.to_str)]
flash.now[:alert] = 'Email or password is invalid'
render 'new'
else
raise "Invalid response #{response.to_str} received."
end
【问题讨论】:
标签: ruby-on-rails rubocop