iは、これらのコントローラはない引用パラメータ
class Checkout::PaymentsController < ApplicationController
before_action :params
def create
if Order.where(:date => params[:date]).present?
redirect_to reserva_path
end
end
def params
params.require(:Order).permit(:date)
end
end
class Products::ReservesController < ApplicationController
before_action :set_product, only: [:show]
def index
@products = Product.all
end
def show
@product = Product.find(params[:pr_id])
end
def set_product
@partner = Product.find(params[:pr_id])
end
エンド
とビュー(show.html.erb)
<div class="detail">
<h3><%= @product.name %></h3>
<p><%= @product.description %></p>
<h4>R$ <%= @product.price %></h4>
<h4>Escolha a data</h4>
<%= form_tag(checkout_payments_path) do%>
<%= hidden_field_tag :product_id, @product.id %>
<div class="data">
<%= date_select(:date, :date, start_year: 2017) %>
</div>
<%= submit_tag "Alugar", class: "btn btn-success"%>
<% end %>
show.html.erbを持つことができますCheckout/Paymentコントローラにproduct_idとdate_selectの日付をパラメータとして送信しますが、コントローラを引用できないというエラーが表示されます(返品アクションコントローラパラメータのインスタンス) 何が間違っていますか?
OBS:コントローラが別の名前空間
EDITにされています。サーバーログのエラー
Started POST "/checkout/payments" for ::1 at 2017-07-02 12:25:19 -0300
Processing by Checkout::PaymentsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"XJdLe2QQww6MvWQ+XWExHlkTAJ7EOD316nxXf8m2YC4HapWtKMb1ciscGZUUNzmCOCuIugsgShYiDj102AfEUg==", "product_id"=>"1", "dates"=>{"{:start_year=>2017}(3i)"=>"2", "{:start_year=>2017}(2i)"=>"7", "{:start_year=>2017}(1i)"=>"2017"}, "commit"=>"Alugar"}
Completed 500 Internal Server Error in 92ms (ActiveRecord: 4.0ms)
TypeError (can't quote ActionController::Parameters):
app/controllers/checkout/payments_controller.rb:4:in `create'
EDIT 2: 私は日付がハッシュとして渡されました、
Processing by Checkout::PaymentsController#new as HTML
Parameters: {"utf8"=>"✓", "product_id"=>"1", "date"=>{"date"=>"201-01-08"}, "commit"=>"Alugar"}
Rendering checkout/payments/new.html.erb within layouts/application
Rendered checkout/payments/new.html.erb within layouts/application (0.0ms)
User Load (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 8 ORDER BY `users`.`id` ASC LIMIT 1
Rendered shared-templates/_header.html.erb (8.0ms) [cache miss]
Completed 200 OK in 356ms (Views: 324.7ms | ActiveRecord: 0.0ms)
を記録見ます
コントローラに追加しました:
def date_params
params.require(:date).permit(:date)
end
が、私はまだこのvallueを持っている:
#<ActionController::Parameters:0x0000000d4d7c60>
正確なエラーメッセージは何ですか?サーバーログに生成された 'params 'を投稿してください。 – Pavan
編集を見てください、 –