Socket
Book a DemoInstallSign in
Socket

golden_retriever

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

golden_retriever

0.0.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

Golden Retriever automatically retrieves resources from the database for actions/controllers that follow rest conventions.

Instructions:

script/plugin git://github.com/DouglasMeyer/golden_retriever.git And add "require GoldenRetriever" to the controllers for which you want your resources automatically retrieved, and the resoures will be loaded under their names. You can also define "resource_find_method" to specify a different find method (like :find_by_name).

Example:

ActionController::Routing::Routes.draw do |map| map.resources :users, :has_many => :posts end

class PostsController < ApplicationController require GoldenRetriever

In this controller, you'll have access to @user, which is

the same as: User.find(params[:user_id])

def index # @posts will be the same as @user.posts render :json => @posts end def show # @post will be the same as @user.posts.find(params[:id]) render :json => @post end def new # @post will be the same as @user.posts.build render :json => @post end

private

def resource_find_method(model_name) model_name == 'post' ? :find_by_name : :find end

end

FAQs

Package last updated on 04 Feb 2010

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.