嗨,我在show.html.erb中显示了估计预算
我正在使用这段代码:
<%= current_user.agency.project_procurement_management_plans.map{|p| p.total_estimated_budget.to_s} %>
但随后,输出变为:
["117000.5"]
我怎样才能分离里面的输出[""]
打赌是因为数组(?),但是我该如何防止呢?
同样,当我在控制器中执行此代码时:
def create
@project_procurement_management_plan = ProjectProcurementManagementPlan.new(params[:project_procurement_management_plan])
respond_to do |format|
if @project_procurement_management_plan.save
format.html { redirect_to @project_procurement_management_plan, notice:"#{@project_procurement_management_plan.code} was successfully created." }
format.json { render json: @project_procurement_management_plan, status: :created, location: @project_procurement_management_plan }
else
#change me soon
format.html { redirect_to new_project_procurement_management_plan_path, alert:"#{@project_procurement_management_plan.errors.full_messages}"}
format.json { render json: @project_procurement_management_plan.errors, status: :unprocessable_entity }
end
end
end
错误消息位于[""]
例如
["Name can't be blank","The password is incorrect"]
等等。
任何解决方法将不胜感激。谢谢。