The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Prototyping With Rapid Resource: A Proof of Concept

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jeremy Voorhis

Posts: 212
Nickname: jvoorhis
Registered: Oct, 2005

Jeremy Voorhis is a Rubyist in northeast Ohio.
Prototyping With Rapid Resource: A Proof of Concept Posted: Aug 4, 2006 2:13 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jeremy Voorhis.
Original Post: Prototyping With Rapid Resource: A Proof of Concept
Feed Title: JVoorhis
Feed URL: http://feeds.feedburner.com/jvoorhis
Feed Description: JVoorhis is a Rubyist in northeast Ohio. He rambles about Ruby on Rails, development practices, other frameworks such as Django, and on other days he is just full of snark.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jeremy Voorhis
Latest Posts From JVoorhis

Advertisement

This is still unreleased, but i am toying with controller macros as a rapid prototyping tool for resources. Just add models, .rhtml, .rjs and .rxml templates.

ActionController::Base#define_actions accepts a parameter which specifies the set of actions to be included. The protected methods resource_name, collection_name, resource, find_collection and find_member provide an api which the actions build upon and may be overridden as needed. Actions may also be overridden piecemeal.

Routes


ActionController::Routing::Routes.draw do |map|
  map.resources :entries do |entries|
    entries.resources :comments
  end

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id'
end

Controllers:


class EntriesController < ApplicationController
  define_actions :crud
end

class CommentsController < ApplicationController
  define_actions :crud

  protected
    def find_collection
      Comment.find :all,
          :conditions => ['entry_id = ?', params[:entry_id],
          :order => 'created_at'
    end

    def find_member
      entry = Entry.find params[:entry_id]
      entry.comments.find params[:id]
    end
end

Read: Prototyping With Rapid Resource: A Proof of Concept

Topic: Self destructing code Previous Topic   Next Topic Topic: RubyConf 2006 Registration is Open

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use