【发布时间】:2014-11-06 06:02:11
【问题描述】:
为了培训,我创建了一个简单的 rails 应用程序。 那么
rails g scaffold Tache titre:string desc:text --skip-stylesheets
rake db:migrate
rails g bootstrap:install static
之后,我启动服务器,然后单击“添加 Tache”,填写 2 个字段,然后出现此错误:
参数丢失或值为空:tach
# Never trust parameters from the scary internet, only allow the white list through.
def tach_params
params.require(:tach).permit(:titre, :desc)
end
end
所以我查看了 taches_controller.rb,我注意到 tache 被截断了。 如果我改变:
params.require(:tach).permit(:titre, :desc)
到
params.require(:tache).permit(:titre, :desc)
它有效。而且这行代码并不是唯一一个最后一个字符被截断的代码。
例子:
def update
respond_to do |format|
if @tach.update(tach_params)
format.html { redirect_to @tach, notice: 'Tache was successfully updated.' }
format.json { render :show, status: :ok, location: @tach }
else
format.html { render :edit }
format.json { render json: @tach.errors, status: :unprocessable_entity }
end
end
end
你能告诉我为什么它被这样截断吗?我一定错过了什么,但我看不到什么。
问候
【问题讨论】:
标签: ruby-on-rails ruby bootstrapping scaffold