Can not save object

reload!; o=Order.find(2); o.exported!; puts Order.find(2).exported_at
=> nil

in order.rb:

def exported!
res = false
if self.exported_at.nil?
self.exported_at = Time.now
res = self.save
else
res = true
end

order_lines.each do |order_line|
  order_line.exported_at = Time.now
  order_line.save
end

res

end

I have no idea why it does not work :frowning: Maybe someone sees something
strange here?

Cheers,
Tomasz

Tom Bak wrote:

I have no idea why it does not work :frowning: Maybe someone sees something
strange here?

ok, here is what was wrong:

before_save :can_be_modified

def can_be_modified
if exported_at.nil?
return true
else
return false
end
end

… still i would like to have that in the model. just being able to set
that field…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs