after update do

if @item.status_changed? ...

On Jul 25, 2011, at 16:43 , Linus Pettersson wrote:

> Hi!
> 
> I have a form with a checkbox called "status" which is a boolean in the 
> database.
> 
> In my controller's update action I want to check if the checkbox has changed. 
> Something like this:
> 
> if @item.status != params[:item][:status]
>   params[:item][:position] = nil
> end
> 
> But this doesn't work as the params[:item][:status] is "0" (an int as a 
> string)
> And the @item.status is false/true (a bool)
> 
> I have tried to use the .to_i on the status param to make it into an int, but 
> it still doesn't work. I guess there is no .to_bool? :)
> 
> So, how do I do this comparison? I'm new to Rails and these small things 
> makes be a bit puzzled :)
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/rubyonrails-talk/-/P7BRyWdhMwwJ.
> 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-talk?hl=en.

-- 
===============================================================================
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===============================================================================

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

Reply via email to