Search code examples
ruby-on-railslintrubocop

Ruby on Rails - Rubocop throwing Lint/Syntax: unexpected token tCOMMA


Rubocop is throwing this error:

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

Here is what the code looks like:

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

Even when changing it back to render :new, status: :unprocessable_entity it ask me to change it to render (:new, status: :unprocessable_entity), i have tried everything under the sun but still no luck

Any help would be much appreciated i am able to invite you to my GitHub if you wish to look further


Solution

  • This isn't a RuboCop issue, running it with ruby -w reports it as invalid.

    The problem is the space after render. Remove that and it's valid.