_will_change! vs. hidden field for :update_at

I found a rails bug that I submitted https://github.com/rails/rails/issues/11031 that was causing a problem for BMC passwords not to save.

As a workaround, I added <%= f.hidden_field :updated_at, :value => Time.now %> to _interfaces/form.html.erb so now the interfaces are ALWAYS dirty and the database table nics is always updated for each host update (which info changed or not)

This introduced a new permissions bug #2707.

My question is does it make more sense to keep f.hidden_field :updated_at or enter some logic using the magic method _will_change! which tells Rails that the record is dirty (in case Rails didn't figure it out). I would need to loop through the interfaces before @host.update_attributes(params[:host]) and run the method attrs_will_change! on each interface instance.

Regards,

Joseph

> I found a rails bug that I submitted
> accepts_nested_attributes_for does not update child field if it is serialized AND no other fields are dirty · Issue #11031 · rails/rails · GitHub that was causing a problem
> for BMC passwords not to save.
>
> As a workaround, I added <%= f.hidden_field :updated_at, :value =>
> Time.now %> to _interfaces/form.html.erb so now the interfaces are ALWAYS
> dirty and the database table nics is always updated for each host update
> (which info changed or not)
>
> This introduced a new permissions bug #2707.
>
> My question is does it make more sense to keep f.hidden_field :updated_at
> or enter some logic using the magic method _will_change! which tells Rails
> that the record is dirty (in case Rails didn't figure it out). I would
> need to loop through the interfaces before
> @host.update_attributes(params[:host]) and run the method
> attrs_will_change! on each interface instance.
>
+1 to using will_change!

Ohad

··· On Tue, Jun 25, 2013 at 6:57 PM, Joseph Magen wrote:

Regards,

Joseph


You received this message because you are subscribed to the Google Groups
“foreman-dev” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.