ruby-on-rails – Rails 4. Ошибка No route matches [PUT] “/client/orders”


I'm trying to create an online store checkout process. The user opens the cart (Cart object), in which the products (LineItem objects) are visible. Together with this, an Order object is immediately created, into which the finished order will be written. This is what Client :: CartsController looks like:

def index
  if @cart.nil? || @cart.line_items.count == 0
    @order  =
    @cart   = @cart.line_items.includes(:item)

This is how the basket itself looks:

= simple_form_for [:client, @order], url: client_orders_path, method: :post, action: 'create' do |f|
  - if user_signed_in?
    = f.input :user_id, as: :hidden, input_html: { value: }
  %table.table.table-hover.table-bordered#cartTable{ 'data-attr_id' => session[:cart_id] }

  Здесь в таблице описание заказов

  = f.input :address
  = f.input :phone_num, as: :tel
  - if user_signed_in?
    = f.button :submit, 'Оформить заказ', class: 'btn-primary'

Further, by clicking the "Checkout" button, the form should go to the Client :: OrdersController, but I see the following error:

No route matches [PUT] "/client/orders". 

Here is the routes.rb file

Rails.application.routes.draw do

scope 'admin' do
  devise_for :admins, :controllers => {
    :confirmations        => 'admin/admins/confirmations',
    # :omniauth_callbacks   => 'admin/admins/omniauth_callbacks',
    :passwords            => 'admin/admins/passwords',
    :registrations        => 'admin/admins/registrations',
    :sessions             => 'admin/admins/sessions',
    :unlocks              => 'admin/admins/unlocks',

scope 'client' do
  devise_for :users, :controllers => {
    :confirmations        => 'client/users/confirmations',
    # :omniauth_callbacks   => 'admin/admins/omniauth_callbacks',
    :passwords            => 'client/users/passwords',
    :registrations        => 'client/users/registrations',
    :sessions             => 'client/users/sessions',
    :unlocks              => 'client/users/unlocks',

namespace :admin do
  root 'items#index'
  resources :items

namespace :client do
  root 'items#index'
  resources :orders do
    resources :order_items
  resources :carts, :items do
    resources :line_items

root 'client/items#index'

It is not clear to me why the PUT method is being called in this case. Now, apparently, in order to avoid an error, it lacks an id, but I need to call the create action. How do you set the form so that there is no such error and the request goes to OrderControoler # create?


Run the command

rake routes

See what paths are available for / client / orders For PUT, the path must be with an identifier: id


Your path is not tied to an order with a specific id

No route matches [PUT] "/client/orders". 
Scroll to Top