Class: FastExt::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- FastExt::ApplicationController
- Defined in:
- app/controllers/fast_ext/application_controller.rb
Direct Known Subclasses
AdminController, MHelpsController, MListItemsController, MListsController, MMenuItemsController, MMenusController, MOrgAccessesController, MOrgsController, MPeopleController, MPersonRolesController, MRolesController, MViewsController, MWindowAccessesController, SessionsController
Instance Method Summary collapse
Instance Method Details
#current_user ⇒ Object
23 24 25 26 27 |
# File 'app/controllers/fast_ext/application_controller.rb', line 23 def current_user # Note: we want to use "find_by_id" because it's OK to return a nil. # If we were to use User.find, it would throw an exception if the user can't be found. @current_user ||= session[:type].find_by_id(session[:user_id]) if session[:type] && session[:user_id] end |
#paginate(record_relation) ⇒ Object
分页方法
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/fast_ext/application_controller.rb', line 8 def paginate(record_relation) limit = params[:limit].to_i start = params[:start].to_i @records = record_relation if limit != 0 @records = record_relation.limit(limit).offset(start) end data ={ :totalCount => record_relation.length, :rows => @records } end |