🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
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

bundlerRubygems
Version
0.0.2
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