Module: ActionController::MobileFu::ClassMethods
- Defined in:
- lib/mobile-fu.rb
Instance Method Summary collapse
-
#has_mobile_fu(set_request_format = true) ⇒ Object
Add this to one of your controllers to use MobileFu.
-
#has_mobile_fu_for(*actions) ⇒ Object
Add this to your controllers to only let those actions use the mobile format this method has priority over the #has_no_mobile_fu_for class AwesomeController < ApplicationController has_mobile_fu_for :index.
-
#has_no_mobile_fu_for(*actions) ⇒ Object
Add this to your controllers to prevent the mobile format from being set for specific actions class AwesomeController < ApplicationController has_no_mobile_fu_for :index.
Instance Method Details
#has_mobile_fu(set_request_format = true) ⇒ Object
Add this to one of your controllers to use MobileFu.
class ApplicationController < ActionController::Base
has_mobile_fu
end
If you don’t want mobile_fu to set the request format automatically, you can pass false here.
class ApplicationController < ActionController::Base
has_mobile_fu false
end
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/mobile-fu.rb', line 56 def has_mobile_fu(set_request_format = true) include ActionController::MobileFu::InstanceMethods before_action :set_request_format if set_request_format helper_method :is_mobile_device? helper_method :is_tablet_device? helper_method :in_mobile_view? helper_method :in_tablet_view? helper_method :is_device? helper_method :mobile_device end |
#has_mobile_fu_for(*actions) ⇒ Object
Add this to your controllers to only let those actions use the mobile format this method has priority over the #has_no_mobile_fu_for
class AwesomeController < ApplicationController
has_mobile_fu_for :index
def index
# Mobile format will be set as normal here if user is on a mobile device
end
def show
# Mobile format will not be set, even if user is on a mobile device
end
end
98 99 100 |
# File 'lib/mobile-fu.rb', line 98 def has_mobile_fu_for(*actions) @mobile_include_actions = actions end |
#has_no_mobile_fu_for(*actions) ⇒ Object
Add this to your controllers to prevent the mobile format from being set for specific actions
class AwesomeController < ApplicationController
has_no_mobile_fu_for :index
def index
# Mobile format will not be set, even if user is on a mobile device
end
def show
# Mobile format will be set as normal here if user is on a mobile device
end
end
81 82 83 |
# File 'lib/mobile-fu.rb', line 81 def has_no_mobile_fu_for(*actions) @mobile_exempt_actions = actions end |