# Override list methods for entire app

**URL:** <https://www.ruby-forum.com/t/override-list-methods-for-entire-app/140306>\
**Category:** Rails\
**Created:** [June 12, 2008, 8:32pm UTC](https://www.ruby-forum.com/t/override-list-methods-for-entire-app/140306 "2008-06-12T20:32:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicpon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/4491bb/32.png) [@nicpon](https://www.ruby-forum.com/u/nicpon)\
**Post date:** [June 12, 2008, 8:32pm UTC](https://www.ruby-forum.com/t/override-list-methods-for-entire-app/140306/1 "2008-06-12T20:32:45Z")

</div>

Hello,  
i have a web that lets users login and their login information is stored  
in session. Now, I want to be able to display records from few tables  
based on the username that they entered. So, all these tables have  
user\_id(corresponds to user\_id in the session and id in user table) and  
I want to display the rows only that are for the user that is currently  
logged in with an option to display all the records if needed. What I am  
trying to do is override list globally, but somehow when I define it in  
application.rb as  
def list  
end  
the specific controllers don’t pick the list code, why?

Also, is there better way to handle this kind of scenario?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![nicpon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/4491bb/32.png) [@nicpon](https://www.ruby-forum.com/u/nicpon)\
**Post date:** [June 12, 2008, 8:40pm UTC](https://www.ruby-forum.com/t/override-list-methods-for-entire-app/140306/2 "2008-06-12T20:40:57Z")

</div>

have you removed the list function from the specific controllers?

let’s see your application.rb and one of the specific controllers.

On Jun 12, 2:32 pm, Michal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![nicpon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/4491bb/32.png) [@nicpon](https://www.ruby-forum.com/u/nicpon)\
**Post date:** [June 12, 2008, 8:52pm UTC](https://www.ruby-forum.com/t/override-list-methods-for-entire-app/140306/3 "2008-06-12T20:52:46Z")

</div>

class ApplicationController \< ActionController::Base  
include AuthenticatedSystem  
session :session\_key =\> ‘\_adam\_session\_id’  
before\_filter :login\_required, :except =\> ‘login’

ActiveScaffold.set\_defaults do |config|  
config.dhtml\_history = false  
config.security.current\_user\_method = :current\_login  
end

def list  
render :layout =\> false  
end

end  
class HomeCaseController \< ApplicationController  
active\_scaffold :home\_case do |config|  
end

def conditions\_for\_collection  
@condition = “login\_id = #{session[:login]}”  
end

end  
As you can tell at this point I have conditions for collection on the  
specific controller level, but I want to crate a general list in  
application.rb and possibly do conditioning there or somewhere in the  
helper if thats better?

julian wrote:

> have you removed the list function from the specific controllers?
> 
> let’s see your application.rb and one of the specific controllers.
> 
> On Jun 12, 2:32ï¿½pm, Michal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![nicpon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/4491bb/32.png) [@nicpon](https://www.ruby-forum.com/u/nicpon)\
**Post date:** [June 12, 2008, 9:11pm UTC](https://www.ruby-forum.com/t/override-list-methods-for-entire-app/140306/4 "2008-06-12T21:11:06Z")

</div>

maybe add this to your ActiveScaffold config -\>  
config.actions.exclude :list

e.g.

ActiveScaffold.set\_defaults do |config|  
config.dhtml\_history = false  
config.security.current\_user\_method = :current\_login  
config.actions.exclude :list  
end

---

<div class="post-metadata">

**Author:** ![nicpon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/4491bb/32.png) [@nicpon](https://www.ruby-forum.com/u/nicpon)\
**Post date:** [June 12, 2008, 9:02pm UTC](https://www.ruby-forum.com/t/override-list-methods-for-entire-app/140306/5 "2008-06-12T21:02:11Z")

</div>

I think the active\_scaffold call is probably redefining the list  
method (though I’ve never used active scaffold). You might want to  
put your list method in a module or something and then include it  
after the active\_scaffold call. It depends on what you want to do.  
If you still need the active\_scaffold list method, then you might want  
to alias\_method\_chain or something… It all depends on the specific  
situation and on what active\_scaffold is actually doing (which I have  
no idea about).

On Jun 12, 2:52Â pm, Michal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
