###前提・実現したいこと
CKEditorを使い投稿画面を作成しています。
やりたいこととしましては、複数のユーザー(deviseで管理)が投稿画面を使える仕様なのですが、CKEditorの仕様?なのか、他の人がuploadした画像も表示されてしまうようになっています。
こちらの記事でやりたいこととドンピシャのことをやっているのですが、こちらの方法を試したところ、ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
というエラーが出てしまいます。
該当部分となるpictures_controller.rb
です。
Ruby
1def index 2 @pictures = Ckeditor.picture_adapter.find_all(ckeditor_pictures_scope).where(assetable_id: current_user.id) 3 @pictures = Ckeditor::Paginatable.new(@pictures).page(params[:page]) 4 # respond_with(respond_with(@pictures, :layout => @pictures.first_page?)) do |format| 5 # format.html { render } 6 # end 7 respond_with(@pictures, :layout => @pictures.first_page?) 8 end
エラー
- 上記のrespond_withは非推奨であるというエラーが出ます。
- indexメソッドの一番上でassetable_idをwhere句で検索していますが、デフォルトではassetable_idというカラムは存在しないので、えらーが出る。
こちらの機能を実装できた方いますでしょうか?
エラーが出てるタイミングはCkeditor::PicturesControllerのindexメソッドコール時ですよね?また、コンソール側(rails consoleでおそらくローカルサーバーをたててると思います)になにかエラーログは表示されていませんか?
def index binding.pry @pictures = Ckeditor.picture_adapter.find_all(ckeditor_pictures_scope).where(assetable_id: current_user.id) @pictures = Ckeditor::Paginatable.new(@pictures).page(params[:page]) # respond_with(respond_with(@pictures, :layout => @pictures.first_page?)) do |format| # format.html { render } # end respond_with(@pictures, :layout => @pictures.first_page?) end のようなエラーが出ます。。。