大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 缺少param或值为空,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
错误 – 参数丢失或值为空:客户
def customer_params params.require(:customer).permit( :first_name,:last_name,:email,:password,:password_confirmation) end end
DetailsController.rb
class My::Account::DetailsController < MyController def show @customer = current_user end def update @customer = current_user @customer.update_attributes(customer_params) if @customer.errors.any? render :action => :show else redirect_to my_account_details_path,:notice => 'Account details updated' end end private def customer_params params.require(:customer).permit( :first_name,:password_confirmation) end end
视图
.account.container .row = render :partial => '/my/account/sidebar' .section %h2 Your account details = simple_form_for @customer,:url => my_account_details_path,:method => :put,:html => { :class => 'form-horizontal'} do |form| .field = form.input :first_name .field = form.input :last_name .field = form.input :email,:as => :email %hr %h4 Leave password fields blank to keep the exisTing password %hr .field = form.input :password,:input_html => { :value => '' } .field = form.input :password_confirmation,:input_html => { :value => '' } .field-actions %button.btn.btn-priMary{type: "submit"} Save
以上是大佬教程为你收集整理的ruby-on-rails – 缺少param或值为空全部内容,希望文章能够帮你解决ruby-on-rails – 缺少param或值为空所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。