On 9/19/06, Eric Fleming <[EMAIL PROTECTED]> wrote:
Perhaps validation failed?
if @entity.save
# save succeeded and id assigned from database
@somevar = @entity.id
else
# validation errors prevented save
puts @entity.errors.inspect
end
jeremy
I was trying to do something line Entity.new.save.id to create a new Entity, save it, and return the id to the local variable @entity. After working with it, it doesn't work. Is there another way to do this without having to go to something like:
@entity = Entity.new
@entity.save
@somevar = @entity.id
I am new to Ruby and Rails, so please forgive me if this is a dumb question. I come from the land of Coldfusion and something like this would work there. Any insight would be appreciated.
Perhaps validation failed?
if @entity.save
# save succeeded and id assigned from database
@somevar = @entity.id
else
# validation errors prevented save
puts @entity.errors.inspect
end
jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
