Hey guys,

Xavier Noria wrote:

>  If you save and change an attribute in the next line
> what should the flags say?


.saved? should be true - I'm just proposing something pretty simple  
(what was the result of the last #save ?)


Jack Christensen wrote:

> !(model.new_record? || model.changed?)

This is great idea - it doesn't work for the reload case, but I don't  
think it needs to for the controller case


John D. Hume wrote:

> it just looked at @whatever.errors.empty?

This also works great - and you can use the existence of the @errors  
var to find if a save (or validation) has been attempted.
(Also doesn't work for the reload case)

However, making #saved? depend on the existing internals would be a  
bad idea in my view, because it'd so much
clearer, and less prone to break if these other things change in  
implementation, to just have an instance variable tracking this

But I take your point on the semantics of saved? - it should be called  
#instance_saved?, in which case it's fugly and seems to  show
that it probably shouldn't be in the API


Summarizing:
You can already do (most of) this, using ARs state.  And it's a bit  
undermotivated when fleshed out.  So keep as a plugin, if it's  
required at all.

Thanks very much for the input guys! - Saved me cluttering up  
lighthouse.

Cheers,
Ian

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to