Rails 3.2 アプリケーションでインプレース編集用の gem 'jeditable-rails' を使用しています
def update
@article = Article.find(params[:id])
@article.update_attributes(params[:article])
render :layout => false if request.xhr?
end
そして私の記事/ update.js.slim
私は持っている
- unless @article.errors.empty?
| $("#error_msg").html(@article.errors);
- else
| $("#success_msg").html("updated successfully");
しかし、更新を行うと、更新されてjsファイルに移動し、そのままのようにレンダリングされます。like$("#error_msg").html(@comment.errors);
がそのまま印刷されるか、$("#success_msg").html("updated successfully")
編集 :
記事のタイトルだけを編集するために jeditable プラグインを使用しています。記事のタイトルを更新し、jsファイルをそのままレンダリングします
ここで得た応答はjsonです。これを解決する方法。提案を与える