Module: SimpleRest::ActionControllerMethods
- Defined in:
- lib/simple_rest/action_controller_methods.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#json_request_handling_filter ⇒ Object
FIXME: add decode exception handling.
- #redirect_back_or_default(default) ⇒ Object
- #simple_rest(data, opts = {}) ⇒ Object
- #store_location ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 |
# File 'lib/simple_rest/action_controller_methods.rb', line 3 def self.included(base) base.extend(ClassMethods) base.before_filter :json_request_handling_filter base.respond_to :js, :xml, :jsonp, :pdf, :yaml, :html end |
Instance Method Details
#json_request_handling_filter ⇒ Object
FIXME: add decode exception handling
18 19 20 21 22 23 24 |
# File 'lib/simple_rest/action_controller_methods.rb', line 18 def json_request_handling_filter if params[:_json] json_params = ActiveSupport::JSON.decode(params[:_json]) params.delete(:_json) params.merge!(json_params) end end |
#redirect_back_or_default(default) ⇒ Object
35 36 37 38 |
# File 'lib/simple_rest/action_controller_methods.rb', line 35 def redirect_back_or_default(default) redirect_to(session[:return_to] || default) session[:return_to] = nil end |
#simple_rest(data, opts = {}) ⇒ Object
26 27 28 29 |
# File 'lib/simple_rest/action_controller_methods.rb', line 26 def simple_rest(data, opts = {}) ::ActiveSupport::Deprecation.warn("simple_rest is deprecated. Please use respond_with instead") respond_with data, opts end |
#store_location ⇒ Object
31 32 33 |
# File 'lib/simple_rest/action_controller_methods.rb', line 31 def store_location session[:return_to] = request.request_uri end |