2014-07-10 30 views
6

Rails için yeni. Aşağıdan hatayı alıyorum. Sorunun ne olduğunu anlıyorum, ancak nasıl düzelteceğimi bilmiyorum?param eksik ya da değer boş

Hata - param eksik veya değeri boş: Müşteri

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, 
     :last_name, 
     :email, 
     :password, 
     :password_confirmation) 
    end 
    end 

Görünüm

.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 
+1

Olduğu gibi değiştirin Url, kaydın UPDATE yolunu göstermez mi? yani:: url => update_my_account_details_path'? Ayrıca, 'simple_form_for' için tüm bu seçenekleri el ile ayarlamanız gerekmemelidir, aşağıdakiler işe yaramalıdır '= simple_form_for @customer, html: {class:' form-horizontal '}' – MrYoshiji

+0

'Params' karma değerinin değeri nedir? belki bu tam hata mesajı/backtrace ile güncelleyin?) –

+0

Modeliniz nasıl görünüyor? – Mavis

cevap

9

Öyle o user olarak geliyor, çünkü ve customer değil. Ben inanıyorum çünkü bir User ve Customer (koddan tahmin) olan current_user kullanıyorsunuz. params.require(:user).permit(blah)

İlgili konular