Ruby on rails Can';更新属性时,无法获取存储的值

Ruby on rails Can';更新属性时,无法获取存储的值,ruby-on-rails,ruby,update-attributes,Ruby On Rails,Ruby,Update Attributes,我正在尝试为版主做一个评分系统,在这个系统中,他们可以选择每个项目作为“编辑选择” 我已经添加了一个:编辑器_pick列到photos表(boolean) 并在部分中为每个项目添加了一个表格,以便在其中包含一个复选框: <% if controller_name == "photos" %> <%= simple_form_for [@user, @photo] do |f| %> <%= f.input :editor_pick, label: "Po

我正在尝试为版主做一个评分系统,在这个系统中,他们可以选择每个项目作为“编辑选择”

我已经添加了一个
:编辑器_pick
列到
photos
表(
boolean

并在部分中为每个项目添加了一个表格,以便在其中包含一个复选框:

<% if controller_name == "photos" %>
  <%= simple_form_for [@user, @photo] do |f| %>
    <%= f.input :editor_pick, label: "Portada" %>
    <%= f.submit "Pick" %>
  <% end %>
<% end %>
编辑 参数编辑
您是否将
editor\u pick
添加到您的
photo\u params
方法?您没有显示
photo\u params
方法请查看我的编辑。谢谢你能发布你的
参数所包含的内容吗?特别是
params[:photo][:editor\u pick]
的值,并提供更新请求的日志
def by_zone
  @photo = Photo.find_by(params[:id])
  @user = @photo.user
  render :index
end

def update
  @photo = Photo.friendly.find(params[:id])
  if @photo.update_attributes(photo_params)
    redirect_to [current_user, @photo], notice: 'El spot se ha actualizado.'
  else
    render 'edit'
  end
end
  def photo_params
    params.require(:photo).permit(:editor_pick,:url,:remote_photo_url,:thumbnail_cache ,:order,:string_tags,:tag_list, :sponsored, :photo, :terms, :title,:description,:category_id,:zone_id, :crop_x, :crop_y, :crop_w, :crop_h, sponsors_attributes: [:name, :description, :web, :facebook, :twitter, :sponsored_avatar])
  end
Started PATCH "/users/enrique-isasi-12/photos/rustic-plastic-table" for 127.0.0.1 at 2015-01-14 16:43:55 +0100
Processing by PhotosController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"wB2SmOT0zR0dwIIguRhzFdctY51LX333CzGYelxS4Hs=", "photo"=>{"editor_pick"=>"1"}, "commit"=>"Pick", "user_id"=>"enrique-isasi-12", "id"=>"rustic-plastic-table"}
  User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 5 ORDER BY "users"."id" ASC LIMIT 1
  Notification Load (0.3ms)  SELECT "notifications".* FROM "notifications" WHERE "notifications"."user_id" = $1 AND "notifications"."viewed_at" IS NULL ORDER BY "notifications"."created_at" DESC LIMIT 30  [["user_id", 5]]
  Notification Load (0.2ms)  SELECT "notifications".* FROM "notifications" WHERE "notifications"."user_id" = $1 AND (viewed_at IS NOT NULL) ORDER BY "notifications"."created_at" DESC LIMIT 30  [["user_id", 5]]
  Photo Load (0.4ms)  SELECT "photos".* FROM "photos" WHERE "photos"."slug" = 'rustic-plastic-table' ORDER BY "photos"."id" ASC LIMIT 1
   (0.4ms)  BEGIN
  Category Load (0.3ms)  SELECT "categories".* FROM "categories" WHERE "categories"."id" = $1 ORDER BY "categories"."id" ASC LIMIT 1  [["id", 2]]
  Zone Load (0.3ms)  SELECT "zones".* FROM "zones" WHERE "zones"."id" = $1 ORDER BY "zones"."id" ASC LIMIT 1  [["id", 6]]
  ActsAsTaggableOn::Tag Load (0.2ms)  SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL)  [["taggable_id", 26], ["taggable_type", "Photo"]]
  SQL (0.6ms)  UPDATE "photos" SET "editor_pick" = $1, "updated_at" = $2 WHERE "photos"."id" = 26  [["editor_pick", true], ["updated_at", Wed, 14 Jan 2015 15:43:55 UTC +00:00]]
false  ActsAsTaggableOn::Tag Load (0.2ms)  SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL)  [["taggable_id", 26], ["taggable_type", "Photo"]]
   (6.1ms)  COMMIT
Redirected to http://localhost:3000/users/enrique-isasi-4/photos/rustic-plastic-table
Completed 302 Found in 31ms (ActiveRecord: 9.7ms)