Creating object in database without showing view to user
Posted
by samuil
on Stack Overflow
See other posts from Stack Overflow
or by samuil
Published on 2010-03-17T18:38:42Z
Indexed on
2010/03/17
18:41 UTC
Read the original article
Hit count: 173
I have controller with action new
, and I want it to create ActiveRecord::Base descendant object, and write it into database (without showing it to user).
def new
active_order = current_user.orders.find {|o| o.status > 0 }
active_order = Order.new if active_order.nil?
(...)
end
Order.new
creates local object, but my question is -- how to make Rails to fill it with default values and write to database?
© Stack Overflow or respective owner