Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
tasks
test
MIT-LICENSE
README.textile
Rakefile
init.rb
install.rb
uninstall.rb

README.textile

ParentResources

Simple parent object filter for polymorphic resource controllers. More info from Val Aleksenko and Davis Cabral

Example

Example controller:

  
    class CommentsController < ApplicationController
      parent_resources :article, :document
      
      def new
        @parent = parent_object
        @comment = Comment.new
      end
      
      def create
      
        @parent = parent_object
        @comment = @parent.comments.build(params[:comment])
      
        if @comment.valid? and @comment.save
          redirect_to send("#{ parent_type }_url", @parent)
        else
          render :action => 'new'
        end
      end
    end
  
Something went wrong with that request. Please try again.