get :show, with: :id do post = Post.find(params[:id]) @post_decorator = PostDecorator.new(post) render ‘posts/show’ end end app/views/posts/show.slim - if @post_decorator.is_new_page? = image_tag @post_decorator.image app/decorators/posts_decorator.rb class PostDecorator attr_reader :post def initialize(post) @post = post end def image_url if self.image.present? self.image.url else ‘default.png’ end end end දࣔ༻ͷϩδοΫΛ%FDPSBUPSʹҠ͢
new instance' do post = create(:post) @post_decorator = PostDecorator.new(post, self) expect(@post_decorator.image_url).to eq ‘default.png’ end end ςετॻ͖͘͢ͳΔ
[--root=ROOT] # The root destination # Default: . -a, [--app=APP] # The application destination path # Default: /app -d, [--destroy] -n, [--namespace=NAMESPACE] # The name space of your padrino project Description: padrino-gen decorator generates a new Padrino decorator ͔͍͔ͭͨ