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

def_resource

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

def_resource

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

DefResource

A way to DRY up Rails Controllers that are essentially providing an HTTP interface for a REST Resource.

Installation

Add this line to your application's Gemfile:

gem 'def_resource'

And then execute:

$ bundle

Usage

The simplest way to use this gem is to execute the def_resource method in a controller

class UsersController < ApplicationController
  def_resource
end

This essentially creates generic index, new, show, create, edit, update, and destroy methods on your controller for the User model. If that is all you need, then you're done. Of course you can override any of those method with your own by simply defining them in your controller.

Accessing your Models

For member actions, you can access the model instance in the view in one of two ways:

  • The generic resource method
  • The name of the model (eg: user)

For collection actions (like index), the collection can be accessed in one of two ways:

  • The generic resources method
  • The plural name of the model (eg: users)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 11 Apr 2013

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