【发布时间】:2014-05-30 14:43:25
【问题描述】:
我有一个使用 postgresql 的 rails 4 应用程序。我还有一个 backbone.js 应用程序,它将 JSON 推送到 rails 4 应用程序。
这是我的控制器:
def create
@product = Product.new(ActiveSupport::JSON.decode product_params)
respond_to do |format|
if @product.save
format.json { render action: 'show', status: :created, location: @product }
else
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end
def product_params
params.require(:product).permit(:title, :data)
end
我正在尝试解析 JSON 并插入产品,但在插入时出现错误:
TypeError (no implicit conversion of ActionController::Parameters into String):
感谢大家的帮助!
【问题讨论】:
标签: ruby-on-rails ruby json postgresql