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だけを使うと正しく動作しますが、それは私が探しているものではありません。 –