# Any way to stop notify(method) in a model?

**URL:** <https://www.ruby-forum.com/t/any-way-to-stop-notify-method-in-a-model/188437>\
**Category:** Rails\
**Created:** [May 11, 2010, 10:54pm UTC](https://www.ruby-forum.com/t/any-way-to-stop-notify-method-in-a-model/188437 "2010-05-11T22:54:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 11, 2010, 10:54pm UTC](https://www.ruby-forum.com/t/any-way-to-stop-notify-method-in-a-model/188437/1 "2010-05-11T22:54:33Z")

</div>

I am adding a function to check for 2 digit dates and change them into  
4 digit before a Date.new has time to choke on it. My model is :

class Person \< ActiveRecord::Base  
belongs\_to :household

def before\_validation

# debugger

```
self.month_int = self.month.to_i
self.day_int = self.day.to_i
self.year_int = self.year.to_i
if (year_int > 0) && (month_int > 0) && (month_int < 13) &&

```

(day\_int \> 0)&& (day\_int \< 32)  
if (self.year\_int \< 100)  
@compare = Date.new(2000+self.year\_int,self.month\_int,  
self.day\_int)  
if (@compare \> Date.today)  
self.year\_int = 1900+self.year\_int  
else  
self.year\_int = 2000+self.year\_int  
end  
self.year = self.year\_int.to\_s  
end  
self.birthday = Date.new(self.year\_int, self.month\_int,  
self.day\_int)  
else  
errors.add(“Date”)  
end  
debugger  
end

validates\_inclusion\_of :month\_int, :in =\> 1…12,  
:message =\> “should be between 1 and 12”  
validates\_inclusion\_of :day\_int, :in =\> 1…31,  
:message =\> “should be between 1 and 31”  
validates\_numericality\_of :year\_int  
validates\_inclusion\_of :sex, :in =\> %w{ M F },  
:message =\> “should be ‘M’ or ‘m’ or ‘F’ or ‘f’”  
validates\_presence\_of :sex, :month, :day, :year  
validates\_date :birthday, :before =\> Date.today+1, :after =\> ‘Jan 1  
1900’, :before\_message =\> ‘Needs to be today or  
before.’, :after\_message =\> ‘Needs to be after 1/1/1900.’

end

since I added the code that changes a model variable, I get 2  
breakpoints from the 2 changes. This is not needed by my app and  
causes a breakpoint that my user won’t know how to bypass. Please help  
with removing this issue. I assume rails is error-checking my code and  
having a fit about not telling the views that a field has changed…

Bob [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 11, 2010, 11:20pm UTC](https://www.ruby-forum.com/t/any-way-to-stop-notify-method-in-a-model/188437/2 "2010-05-11T23:20:18Z")

</div>

On 11 May 2010 21:53, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> self.year\_int = self.year.to\_i  
> self.year = self.year\_int.to\_s  
> :message =\> “should be between 1 and 12”
> 
> end
> 
> since I added the code that changes a model variable, I get 2  
> breakpoints from the 2 changes. This is not needed by my app and  
> causes a breakpoint that my user won’t know how to bypass. Please help  
> with removing this issue. I assume rails is error-checking my code and  
> having a fit about not telling the views that a field has changed…

I am confused about exactly what is the problem that you are having.  
Is it that the code is stopping at the debugger statement in your  
code? If so just remove the debugger statement.

If this is not the problem please be more explicit about what is  
happening.

Colin

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 14, 2010, 5:50am UTC](https://www.ruby-forum.com/t/any-way-to-stop-notify-method-in-a-model/188437/3 "2010-05-14T05:50:18Z")

</div>

It acts like I set a breakpoint, but I haven’t. Not sure why, but this  
problem vanished last night…

Bob

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 14, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/any-way-to-stop-notify-method-in-a-model/188437/4 "2010-05-14T14:31:52Z")

</div>

[Please quote when replying.]

Bob S. wrote:

> It acts like I set a breakpoint, but I haven’t. Not sure why, but this  
> problem vanished last night…

Perhaps the class was cached (which Rails does automatically in  
production) and the cached version included the breakpoints? Then if  
you restarted the server, it would have reloaded the class.

> Bob

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
