Add form submission to page

I’m new to rails. I need help. I’ve created a form that allows the user to customize an item and click a “submit” button. The “submit” button should redirect user to cart page and add the customized item to cart. However, when the “submit” button is clicked, it directs the user to cart page but does not add the item to cart. I’m stuck and am in need of some assistance.

Customs Controller

before_action :authenticate_user!, except: [:index]
    def new
        @prebuilts = Prebuilt.all
        @custom = Custom.new
      end
    def create
        @custom = Custom.new(params.require(:custom).permit(:built_in_game, :color, :crayon_walls, :entertainment_tablets, :manufacturer, :price, :size))
        if @custom.save
            flash[:success] = "new custom jet created"
            redirect_to cart_url
        else
            flash.now[:error] = 'custom jet creation failed'
            render :new, status: :unprocessable_entity
        end
    end

Cart Controller

    def index
    @cart = Prebuilt.all
    render :index
  end

  def show
    @cart = current_cart
   end

   def add_to_cart
    current_cart.add_item(params[:prebuilt_id])
    redirect_to cart_path(current_cart.id)
    flash[:success] = 'Item successfully updated!'
  end

Customs Form Page

before_action :authenticate_user!, except: [:index]
    def new
        @prebuilts = Prebuilt.all
        @custom = Custom.new
      end
    def create
        @custom = Custom.new(params.require(:custom).permit(:built_in_game, :color, :crayon_walls, :entertainment_tablets, :manufacturer, :price, :size))
        if @custom.save
            flash[:success] = "new custom jet created"
            redirect_to cart_url
        else
            flash.now[:error] = 'custom jet creation failed'
            render :new, status: :unprocessable_entity
        end
    end

Cart Page

<% content_for(:html_title) { 'Junior Jets | Cart' } %>

<h1 style="font-family:'Courier New'"><b>YOUR CART</b></h1>

<div class="cart">

<style>
  #right {
    text-align: right;
    background-color: #ffffff;
  }
</style>

<table id="line_items">
  <tr>
    <th>Product</th>
    <th>Qty</th>
    <th class="price">Unit Price</th>
    <th class="price">Full Price</th>
  </tr>

  <% for item in @cart %>
    <tr class="<%= cycle :odd, :even %>
       <td><%=h item.name %></td>
    </tr>
   <% end %>
  </tr>
</table>


  <div id="right">
  <div class="totals">
    <div class="totals-item">
      <label>Subtotal</label>
      <div class="totals-value" id="cart-subtotal">71.97</div>
    </div>
    <div class="totals-item">
      <label>Tax (10%)</label>
      <div class="totals-value" id="cart-tax">3.60</div>
    </div>
    <div class="totals-item">
      <label>Shipping</label>
      <div class="totals-value" id="cart-shipping">15.00</div>
    </div>
    <div class="totals-item totals-item-total">
      <label>Grand Total</label>
      <div class="totals-value" id="cart-total">90.57</div>
    </div>
  </div>
  <a href="http://localhost:3000/checkout">
  <button>Checkout</button>
  </a>
  </div>

</div>

Routes

  get 'cart', to: 'cart#index', as: 'cart';

  post '/add_to_cart/:prebuilt_id' => 'cart#add_to_cart', :as => 'add_to_cart'

  get 'checkout', to: 'pages#checkout', as: 'checkout';

  get 'confirm', to: 'pages#confirm', as: 'confirm';

########################################################################################################

  # root to: redirect('/jets')

  get 'jets', to: 'jets#index', as: 'jets'
  post 'jets', to: 'jets#create'
  get 'jets/new', to: 'jets#new', as: 'new_jet'
  get 'jets/:id/edit', to: 'jets#edit', as: 'edit_jet'
  get 'jets/:id', to: 'jets#show', as: 'jet'
  patch 'jets/:id', to: 'jets#update'
  delete 'jets/:id', to: 'jets#destroy'

  get 'jets/:jet_id/products', to: 'products#index', as: 'jet_products'
  post 'jets/:jet_id/products', to: 'products#create'
  get 'jets/:jet_id/products/new', to: 'products#new', as: 'new_jet_product'
  get '/jets/:jet_id/products/:id/edit', to: 'products#edit', as: 'edit_jet_product'
  get '/jets/:jet_id/products/:id', to: 'products#show', as: 'jet_product'
  patch '/jets/:jet_id/products/:id', to: 'products#update'
  delete '/jets/:jet_id/products/:id', to: 'products#destroy'

  # get 'jets/:jet_id/reviews', to: 'reviews#index', as: 'jet_reviews'
  # post 'jets/:jet_id/reviews', to: 'reviews#create'
  # get 'jets/:jet_id/reviews/new', to: 'reviews#new', as: 'new_jet_review'
  # get '/jets/:jet_id/reviews/:id/edit', to: 'reviews#edit', as: 'edit_jet_review'
  # get '/jets/:jet_id/reviews/:id', to: 'reviews#show', as: 'jet_review'
  # patch '/jets/:jet_id/reviews/:id', to: 'reviews#update'
  # delete '/jets/:jet_id/reviews/:id', to: 'reviews#destroy'
  get 'prebuilts', to: 'prebuilts#index', as: 'prebuilts'
  get 'prebuilts/:id', to: 'prebuilts#show', as: 'prebuilt'


  get 'customs/new', to: 'customs#new', as: 'new_custom'
  post 'custom', to: 'customs#create'

New contributor

user24686287 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật