2017-07-10 10 views
0

特定のブール値がtrueに設定される前に一度しかアクセスできないフォームを作成しようとしています。それと一緒に他の情報を入力すると、わかりませんこれを正しく設定するには、今までのところフォームに問題はありませんが、ユーザーの情報は更新されません。Railsの代替更新フォーム

私はちょうどここに自動的に

それらを作るためにresources:を使用し、ほとんどの時間は、私の形ですので、私の主な問題は、私はルートやフォームを設定する方法がわからないということです。

<%= form_for @user, url: organizer_user_path, method: :put do |f| %> 
. 
. 
. 
<%end%> 

私は入れないと思う私のルートは、すべての

get 'organizer/user', to: "users#organizer_form" 
put 'organizer/user', to: "users#organizer_registration" 

と私のコントローラ

01で正しいです
def organizer_form 
@user = User.find(current_user[:id]) 
end 

def organizer_registration 
    @user = User.find(current_user[:id]) 
    if @user.update_attributes(user_params) 
    redirect_to @user 
    else 
    render 'organizer_form' 
    end 
end 

私は自分のルートをどのように定義し、どのようにフォームに呼び出されるのか、どのようなヘルプに問題があるのでしょうか?ここ

が提出されるのparamsがされています。最後の答えを見つけた

--- !ruby/object:ActionController::Parameters 
parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess 
    utf8: "✓" 
    _method: put 
    authenticity_token: w9zTUQLK+4kZtbvRCfcYfZgn8ma4xSRdbTMy+fktpoHlGADxHSB6u9QBh3K3zv72V/Ys2b3Q1MiKC0Gr+OqNJw== 
    user: !ruby/object:ActionController::Parameters 
    parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess 
     organizer: 'true' 
     contact_name: Name 
     last_name: Last name 
     contact_email: [email protected] 
     cellphone: '1234567' 
     company: '' 
     office_phone: '' 
     website: '' 
    permitted: false 
    commit: continuar 
    controller: users 
    action: organizer_registration 
permitted: false 

これは私のuser_params

def user_params 
    params.require(:user).permit(:name, :email, :password, :password_confirmation, :organizer, :contact_name, :last_name, :contact_email, :cellphone, :company, :office_phone, :website) 
end 
+0

フォーム送信時に生成された 'params'を投稿できますか? – Pavan

+0

私はparamsを投稿しました。私は 'put'と' patch'メソッドの違いを理解するのに苦労しています。 – Bluespheal

+0

'user_params'メソッドを追加しました – Pavan

答えて

0

です!私は

attr_accessor :organizer, :contact_name, :last_name, :contact_email, :cellphone, :company, :office_phone, :website 

となり、何らかの理由でアップデートが中止されたため、アップデートがデータベースに保存されました。

関連する問題