We are implementing the purchase function. I'm in trouble because I can't find the error.

<% = form_with model: (@userdonation, item_purchases_path, id:'charge-form', class:'transaction-form-wrap', local: true) do | f |%>
    <% = render partial:'shared/error_messages', locals: {model: f.object}%>
  <% #Enter card information%>
        Credit card information input
        <label>Card information</label>
      <% = f.text_field'hoge', class: "input-default", id: "card-number", placeholder: "card number (half-width alphanumeric characters)", maxlength: "16"%>
        <% = image_tag'card-visa.gif', class:'card-logo'%>
        <% = image_tag'card-mastercard.gif', class:'card-logo'%>
        <% = image_tag'card-jcb.gif', class:'card-logo'%>
        <% = image_tag'card-amex.gif', class:'card-logo'%>
        <label>Expiration date</label>
        <% = f.text_area'hoge', class: "input-expiration-date", id: "card-exp-month", placeholder: "Example) 3"%>
        <% = f.text_area'hoge', class: "input-expiration-date", id: "card-exp-year", placeholder: "Example) 23"%>
        <label>Security code</label>
      <% = f.text_field "hoge", class: "input-default", id: "card-cvc", placeholder: "4 or 3 digit number on the back of the card", maxlength: "4"%>
  <% #/Enter card information%>
Rails.application.routes.draw do
  devise_for: users
  root to: "items # index"
  resources: items, only: [: new,: create,: show,: edit,: update,: destroy] do
    resources: purchases, only: [: index,: new,: create]
class UserDonation
  include ActiveModel :: Model
  attr_accessor: post_code,: city,: block_number,: building_name,: phone_number,: prefecture_id,: purchases_id,: item_id,: user_id
  with_options presence: true do
    validates: city,: block_number,: phone_number,: prefecture_id
    validates: post_code, format: {with:/\ A [0-9] {3}-[0-9] {4} \ z /, message: "is invalid. Include hyphen (-)"}
    validates: region_id, numericality: {other_than: 0, message: "can't be blank"}
  def save
    Address.create (post_code: post_code, city: city, block_number: block_number, building_name: building_name, phone_number: phone_number, prefecture_id: prefecture_id, purchases_id: purchases_id)
    Purchase.create (item_id: item_id, user_id: user_id)

class PurchasesController
class Purchase
class Address

  • Answer # 1

    This part, model is out of parentheses

    <% = form_with model: (@userdonation, item_purchases_path

    How about changing it as follows?

    <% = form_with (model: @userdonation, item_purchases_path