Tôi vừa mới bắt đầu với RoR và có câu hỏi: Làm cách nào để chèn dấu thời gian hiện tại (hoặc bất kỳ loại thời gian nào) vào mô hình? Dưới đây bạn thấy chức năng đăng nhập tạo ra.Cách chèn dấu thời gian vào cơ sở dữ liệu đường ray-cột
def create
@log = Log.new(params[:log])
respond_to do |format|
if @log.save
format.html { redirect_to @log, notice: 'Log was successfully created.' }
format.json { render json: @log, status: :created, location: @log }
else
format.html { render action: "new" }
format.json { render json: @log.errors, status: :unprocessable_entity }
end
end
end
Bạn đã tạo mô hình bằng trình tạo đường ray chưa? –