前提
ショッピングサイトを課題で作成しています。
今回顧客側で退会機能の作成をしています。
退会するかしないかを選び、情報を送る際にhiddenn_fieldを使おうと思っているのですがその際にエラーが出てしまいました。
発生している問題・エラーメッセージ
no implicit conversion of false into Hash
翻訳すると【false から Hash への暗黙的な変換はありません】という意味らしいのですが、これは変換できないという意味でしょうか...?
該当のソースコード
RubyonRails
1<%= form_with model: @customer, url:customers_withdraw_path, method: :patch do |f| %> 2 <%= f.submit "退会しない" %> 3 <%= f.hidden_field :is_deleted, false %>#ここでエラーが出ている 4 <%= f.submit "退会する" %> 5 <%= f.hidden_field :is_deleted, true %> 6<% end %> 7
補足情報(FW/ツールのバージョンなど)
RubyonRails
1class Public::CustomersController < ApplicationController 2 3 def show 4 @customer = current_customer 5 end 6 7 def update 8 @customer = current_customer 9 @customer.update(customer_params) 10 redirect_to customers_my_page_path 11 end 12 13 def edit 14 @customer = current_customer 15 end 16 17 def withdraw 18 @customer = current_customer 19 @customer.update(is_deleted: false) 20 redirect_to 21 end 22 23 def unsubscribe 24 end 25 26 private 27 def customer_params 28 params.permit(:last_name, :first_name, :last_name_kana, 29 :first_name_kana, :telephone_number, :postal_code, :address, 30 :email, :password) 31 end 32end
RubyonRails
1class Customer < ApplicationRecord 2 : 3 : 4 #falseなら有効会員、trueなら退会済みの無効会員 5 enum is_deleted: { false: false, true: true } 6: 7: 8end 9
RubyonRails
1<h3>本当に退会しますか?</h3> 2<p>退会すると、会員情報や<br>これまでの購入履歴が閲覧できなくなります。<br> 3退会する場合は、「退会する」をクリックしてください。</p> 4 5<%#= link_to "退会しない", customers_infomation_edit_path %> 6<%#= link_to "退会する", customers_withdraw_path, method: :patch %> 7#↑は以前作ったものですが、念のため残しています。ボタンとして実装したいので 8今回は↓にあるもので実装を考えています。 9 10<%= form_with model: @customer, url:customers_withdraw_path, method: :patch do |f| %> 11 <%= f.submit "退会しない" %> 12 <%= f.hidden_field :is_deleted, false %> 13 <%= f.submit "退会する" %> 14 <%= f.hidden_field :is_deleted, true %>
RubyonRails
1 customers_my_page GET /customers/my_page(.:format) public/customers#show 2 customers_infomation_edit GET /customers/infomation/edit(.:format) public/customers#edit 3 customers_infomation_up_date PATCH /customers/infomation/up_date(.:format) public/customers#update 4 customers_unsubscribe GET /customers/unsubscribe(.:format) public/customers#unsubscribe 5 customers_withdraw PATCH /customers/withdraw(.:format) public/customers#withdraw 6
回答1件
あなたの回答
tips
プレビュー