Skip to content

xwmx/parent_resources

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  

About

DRYing Up Polymorphic Controllers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages