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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Sza <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Sza <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Sza <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 Sza <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Jun 12, 3:01 pm, julian <thefool...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 Sza <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > 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 Sza <rails-mailing-l...@andreas-s.net> > > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---