ruby on rails - cant write data to model/database -


i created order scaffold when go on localhost:3000/orders , type data want ( name, email, number ) template missing error .

this 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 orders.rb model :

class order < activerecord::base    has_one :cart  end 

thanks,

michael

you haven't implemented create action controller drops straight through render create view. however, there no create view standard, hence error missing template orders/create...

the create action there create new record , redirect show or index view.

for example:

def create   @order = order.new(order_params)    @order.save   redirect_to @order end 

note, example going; should handling errors save , going new action etc.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -