# Rails coding/design input

**URL:** <https://www.ruby-forum.com/t/rails-coding-design-input/168547>\
**Category:** Rails\
**Created:** [May 22, 2009, 7:29am UTC](https://www.ruby-forum.com/t/rails-coding-design-input/168547 "2009-05-22T07:29:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivekamn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e8c25b/32.png) [@vivekamn](https://www.ruby-forum.com/u/vivekamn)\
**Post date:** [May 22, 2009, 7:29am UTC](https://www.ruby-forum.com/t/rails-coding-design-input/168547/1 "2009-05-22T07:29:13Z")

</div>

Hi,

We have a web app which serves typical social  
content(blogs/forums/streams etc).

All the content is optionally marked with a city. I.e. if a blog post is  
specific to New York, it will be marked so.

The task is to show only city specific information(all over the site) if  
user has set city view preference and show everything to all others.

So I have to add ‘and city == current\_city’ if city\_specifc\_view? to all  
my finders in all my model classes, which is a maintenance night  
mare(especially as there is a risk of this logic changing).

I am wondering what is the right way to apply this logic. Can I do it a  
central place(like overrinding the default find). Is monkey patching an  
option.

Thanks

---

<div class="post-metadata">

**Author:** ![vivekamn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e8c25b/32.png) [@vivekamn](https://www.ruby-forum.com/u/vivekamn)\
**Post date:** [May 22, 2009, 10:17am UTC](https://www.ruby-forum.com/t/rails-coding-design-input/168547/2 "2009-05-22T10:17:30Z")

</div>

On May 22, 6:29 am, Vivekamn Vv [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> So I have to add ‘and city == current\_city’ if city\_specifc\_view? to all  
> my finders in all my model classes, which is a maintenance night  
> mare(especially as there is a risk of this logic changing).
> 
> I am wondering what is the right way to apply this logic. Can I do it a  
> central place(like overrinding the default find). Is monkey patching an  
> option.

I think you’d be better off with a named\_scope (or possibly  
with\_scope).

Fred

---

<div class="post-metadata">

**Author:** ![vivekamn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e8c25b/32.png) [@vivekamn](https://www.ruby-forum.com/u/vivekamn)\
**Post date:** [May 22, 2009, 10:25am UTC](https://www.ruby-forum.com/t/rails-coding-design-input/168547/3 "2009-05-22T10:25:43Z")

</div>

Possibly use default\_scope?

2009/5/22 Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
