Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 最佳位置gem不保存文本区域内容_Ruby On Rails_Ruby On Rails 4_Best In Place - Fatal编程技术网

Ruby on rails 最佳位置gem不保存文本区域内容

Ruby on rails 最佳位置gem不保存文本区域内容,ruby-on-rails,ruby-on-rails-4,best-in-place,Ruby On Rails,Ruby On Rails 4,Best In Place,所以,我不知道为什么,但当我在文本框中输入一些文本,然后刷新页面时,文本不会保存。我使用的是正确的DB字段(描述),所以我不确定出了什么问题 \u photo.html.erb <%= best_in_place photo, :description, type: :textarea, nil: 'Enter a Caption' %> 为什么不节约呢 干杯 更新: class PhotosController < ApplicationController befor

所以,我不知道为什么,但当我在文本框中输入一些文本,然后刷新页面时,文本不会保存。我使用的是正确的DB字段(描述),所以我不确定出了什么问题

\u photo.html.erb

<%= best_in_place photo, :description, type: :textarea, nil: 'Enter a Caption' %>
为什么不节约呢

干杯

更新:

class PhotosController < ApplicationController
  before_filter :authenticate_user!

  def show
    @photo = current_user.photos.find(params[:id])
  end
show.js

$('.modal-title').html('<%= @photo.title %>');
$('.modal-body').html('<%= j(render "modal_photo", photo: @photo) %>');
$('#myModal').modal();
$('.modal title').html('');
$('.modal body').html('');
$('#myModal').modal();
照片\u控制器(snip):

class PhotosController < ApplicationController
  before_filter :authenticate_user!

  def show
    @photo = current_user.photos.find(params[:id])
  end
class photocontroller
这里您需要保存对象而不是单值属性。换成

<%= best_in_place @photo, :description, type: :input %>


请参阅此答案帮助:

我认为您的问题可能出在控制器上:

class PhotosController < ApplicationController
  respond_to :html, :json # Whatever formats you want to respond

  # Other actions...

  def update
    @photo = Photo.find(params[:id])

    respond_to do |format|
      if @photo.update_attributes(params[:photo])
        format.html { # Whatever you want to do... }
        format.json { respond_with_bip(@photo) }
      else
        format.html { # Whatever you want to do... }
        format.json { respond_with_bip(@photo) }
      end
    end
  end
class photocontroller

Best-in-place提供了一种实用方法,您应该在控制器中使用它,以便使用
:json
格式提供javascript端期望的响应

请添加控制器的内容和调用
\u photo.html.erb
partial的视图。当然-我已经用show和photos控制器的相关代码更新了帖子。谢谢请也添加控制器的
更新
操作。您正在使用Rails3或Rails4?Rails 4。让我把它拿走,对不起!