2010-03-02 4 views

답변

2

어쩌면 당신 같은 STH 할 수있는 :

class PostsController < ApplicationController 
    acts_as_special 

    def show 
    @post = Post.find(params[:id]) 
    respond_to do |format| 
     format.html { my_renderer } 
    end 
    end 
end 

및 플러그인 또는 STH 쓰기 :

# Module to Extend a given Controller with the acts_as_special methods 

module MyRenderer 
    def self.included(base) 
    base.extend(ClassMethods) 
    end 

    module ClassMethods 

    def acts_as_special 
     include MyRenderer::InstanceMethods 
    end 
    end 

    module InstanceMethods 
    def my_renderer 
     .. do sth with the code .... 
     render :template => ... 
    end 
    end 
end 


ActionController::Base.class_eval do 
    include MyRenderer 
end 

아니라 당신이 플러그인을 작성해야 해달라고을 YUST 당신은 "당신의"렌더링 확인해야 메서드를 사용할 수 있습니다.

다른/더 나은 방법이 있으면 알려 주시기 바랍니다.

관련 문제