Ruby on Rails - Rubocop 抛出 Lint/语法:意外标记 tCOMMA

问题描述 投票:0回答:1

Rubocop 抛出此错误:

Lint/Syntax: unexpected token tCOMMA
(Using Ruby 3.2 parser; configure using TargetRubyVersion parameter, under AllCops)
      render (:new, status: :unprocessable_entity)

代码如下:

def create
    @company = current_user.companies.build(company_params)

    if @company.save
      redirect_to(company_url(@company), { notice: "Company was successfully updated." })
    else
      render (:new, status: :unprocessable_entity)
    end
  end

即使改回

render :new, status: :unprocessable_entity
,它要求我改成
render (:new, status: :unprocessable_entity)
,我已经尝试了一切,但仍然没有运气

任何帮助将不胜感激,如果您想进一步了解,我可以邀请您访问我的 GitHub

ruby-on-rails lint rubocop
1个回答
0
投票

这不是 RuboCop 问题,使用

ruby -w
运行它会报告它无效。

问题是

render
后面的空格。删除它,它就有效。

© www.soinside.com 2019 - 2024. All rights reserved.