2016-08-21 3 views
0

내 프로젝트에서 draper, decent_exposure 및 decent_decoration 젬을 사용하려고 시도하지만 어떤 것이 올바르게 작동하지 않습니다. 방금 antoher 프로젝트에서이 코드를 복사했기 때문에 이상합니다.expose_decorated가 posts 변수로 작업하지 않습니다. 왜?

class PostsController < ApplicationController 

    expose_decorated(:post) 
    expose_decorated(:posts) 

    def create 
    if post.save 
     redirect_to post_path(post) 
    else 
     render :new 
    end 
    end 

    def update 
    if post.update(post_params) 
     redirect_to post_path(post) 
    else 
     render :edit 
    end 
    end 

    def destroy 
    post.destroy 
    redirect_to posts_path 
    end 

    private 

    def post_params 
     params.require(:post).permit(:title, :content) 
    end 

end 

여기

%h1 Blog 

- posts.each do |post| 
    %p= post.title 
    %p= post.content 

인덱스보기 내가이 오류를 받고 있어요 :

내 컨트롤러는

undefined method `map' for #<Post:0x007f7df88dcca0> 
Did you mean? tap 
+0

'expose : posts, -> {Post.all} 코드로 decent_exposure 만 사용하면 올바로 작동하지만 그게 내가 찾고있는 것이 아닙니다. –

답변

0

내가 그것을 알아 냈어. decent_decoration이 2.0 이상 버전과 호환되는 동안 decent_exposure 버전 3.0.0을 사용했기 때문에 작동하지 않았습니다.

decent_exposure의 버전을 2.3으로 변경했으며 제대로 작동합니다.