newTransaction doesnt save.
Method model:
def self.newTransaction(sesion,date)
t = Transaccion.new(sesion:'sesion',date:'date')
newTransaction.save
end
Controller:
Transaccion.newTransaction("vianny.mo@gmail.com","12-12-12")
Why not just use create
and save your self the extra line
def self.newTransaction(sesion, date)
create(sesion: sesion, date: date)
end
since the method (create) has no receiver, it will be sent to self, which I assume is the same class you want to create the method for
使用t.save
代替newTransaction.save
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.