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