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.
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.
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).