Я сейчас работаю над своим новым веб-приложением.Мои клиенты могут сделать заказ, и после этого они перенаправляются в форму, где они могут предоставить дополнительную информацию, такую как: описание, веб-сайт, адрес электронной почты, пароль ...
Запись уже создана с create
После успешного платежа клиент перенаправляется на мой метод submit
.Я уже пробовал @reservation.update(reservation_params)
, но это не сработало.
Мои маршруты:
resources :reservations, only: [:approve, :decline, :submit] do
member do
match 'submit', via: [:get, :post]
end
end
Мой контроллер бронирования:
class ReservationsController < ApplicationController
before_action :authenticate_user!
before_action :is_admin, only: [:approve, :decline, :your_reservations]
before_action :set_reservation, only: [:approve, :decline, :submit]
def create
service = Service.find(params[:service_id])
if current_user.admin?
flash[:alert] = "Du kannst nicht dein eigenes Angebot kaufen"
elsif current_user.stripe_id.blank?
flash[:alert] = "Füge eine Zahlungsmehtode hinzu"
return redirect_to payment_method_path
else
@reservation = current_user.reservations.build
@reservation.service = service
@reservation.price = service.price
if @reservation.Bearbeitung!
flash[:notice] = "Ihre Anfrage wurde erfolgreich versendet"
ReservationMailer.confirm_email_to_guest(@reservation.user, service).deliver
confirm_sms(service, @reservation)
else
charge(service, @reservation)
end
end
redirect_to submit_reservation_path(@reservation)
end
def submit
redirect_to root_path, alert: "Du hast keine Berechtigung!" unless current_user.id == @reservation.user_id
end
def set_reservation
@reservation = Reservation.find(params[:id])
end
end
Мой submit.html.erb:
<%= form_for submit_reservation_path, method: :post do |f| %>
<div class="form-group">
<label>Aufgabe</label>
<%= f.text_field :description, placeholder: "Aufgabe", required: true, class: "form-control" %>
</div>
<div class="text-center"><%= f.submit "Veröffentlichen", class: "btn btn-primary btn-block" %></div>
<% end %>
Я удалил params.permit(:description)
, так как он не работал.Я ожидал, что дополнительные параметры description
, website
будут вставлены в мою таблицу резервирования, но это не так.
Я несколько раз получал эту ошибку:
ActiveRecord::RecordNotFound (Couldn't find Reservation with 'id'={"id"=>"23"}):