rails控制器不接受rails指南中的参数

时间:2018-02-15 23:45:07

标签: ruby-on-rails

我正在尝试创建一个新的控制器,我正在按照入门教程。我已经将文章重命名为投资以换取不同的东西。我一直收到与我的控制器有关的以下错误

myapp/app/controllers/investments_controller.rb:20: syntax error, unexpected ')', expecting keyword_end

控制器如下所示:

class InvestmentsController < ApplicationController

def show
@investment = Investment.new(params.require(:investment).permit(:title, :text))
end

def new
end

def create
    @investment = Investment.new

    @investment.save
    redirect_to @investment
end


private
  def investment_params
    params.require(:investment).permit(:title, :description))
  end
end

我还在数据库中添加了额外的字符串。将它们添加到params似乎也不起作用

1 个答案:

答案 0 :(得分:1)

你在行尾有双括号

 params.require(:investment).permit(:title, :description))