Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

convenient-actionpack

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convenient-actionpack

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

convenient-actionpack

Under construction... Watch your head.

Making common things easier for ActionController, etc.

Setup

In your Rails 3.1+ project, add this to your Gemfile:

gem 'convenient-actionpack', :git => 'git://github.com/garysweaver/convenient-actionpack.git'

Then run:

bundle install

Usage

Provides a wrap method to rescue StandardError to return an informative JSON error from JSON services instead of HTML when there is an error:

def create
  wrap do
    @my_model.save
    respond_with @my_model
  end
end

If you don't like the standard functionality, you can implement a single error handling method in your ApplicationController to handle errors from all wrapped action methods:

def on_action_error(error)
  case params[:format].to_sym
  when :json
    respond_with({errors: [error.message]}, location: nil, status: :internal_server_error)
  else
    raise error # should include prior backtrace
  end
end

Future

Originally was meant to provide a respond method that would skirt some of the unintuitive behavior of respond_with like #2798, and provide additional functionality, but that is commented for now. Maybe will get to it later. Feel free to fork/submit pull requests.

License

Copyright (c) 2012 Gary S. Weaver, released under the MIT license.

FAQs

Package last updated on 24 Sep 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc