Reputation: 309
i created order scaffold
but when i go on localhost:3000/orders
and type data i want ( name, email, number ) i get TEMPLATE IS MISSING ERROR .
This is my controller:
class OrdersController < ApplicationController
def index
@orders = Order.all
end
def show
end
def new
@order = Order.new
end
def create
end
def order_params
params.require(:order).permit(:name, :number, :email, :pay_type)
end
end
and this is orders.rb
model :
class Order < ActiveRecord::Base
has_one :cart
end
Thanks,
Michael
Upvotes: 0
Views: 39
Reputation:
You haven't implemented your create
action so the controller drops straight through to render a create view. However, there is no create view as standard, hence the error Missing template orders/create...
The create action is there to create a new record and then redirect to the show or index view.
For example:
def create
@order = Order.new(order_params)
@order.save
redirect_to @order
end
Note, this is just an example to get you going; you should be handling any errors from the save and going back to the new action etc.
Upvotes: 2