add_without_safety create new DB entry in controller
Posted
by Karl Entwistle
on Stack Overflow
See other posts from Stack Overflow
or by Karl Entwistle
Published on 2010-06-10T23:04:22Z
Indexed on
2010/06/10
23:13 UTC
Read the original article
Hit count: 219
ruby-on-rails
Im trying to get a controller to create a new account with the user id filled in, this doesn't work in my controller or in the console, why? Any suggestions on how to implement this would be much appreciated.
class PaymentNotification < ActiveRecord::Base
after_create :add_account_to_market
private
def add_account_to_market
if status == "Completed"
line = LineItem.find(:first, :conditions => { :cart_id => cart.id })
line.quantity.times do
Account.new(:user_id => cart.user_id)
end
end
end
end
© Stack Overflow or respective owner