1
我嘗試訪問似乎被允許的params [:person_id],因爲我注意到webtrick日誌中但該表達式返回NilClass。爲什麼?params [:person_id]返回NilClass,雖然允許值
class ClubsController < ApplicationController
private
def set_stored_with_own_address
logger.debug("params[:person_id]: #{params[:person_id].class}") # => NilClass
logger.debug("params: #{params.class}") # => ActionController::Parameters
@stored_with_own_address = params[:person_id].nil?
logger.debug("Was stored with own address: #{@stored_with_own_address}") # => true
end
end
我PARAMS哈希值是:
Parameters: {"utf8"=>"√", "authenticity_token"=>"2HnqCni+Yy2jMY0vKhUNcAreD1vdAISrLkURuTso7AM=", "club"=>{"caption"=>"xxx", "region_id"=>"1", "bdk_number"=>"4711", "website"=>"xxx", "person_id"=>"1", "address_attributes"=>{"street"=>"", "street_visibility"=>"0", "zip"=>"", "city"=>"", "zip_city_visibility"=>"0", "phone"=>"", "phone_visibility"=>"0", "mobil"=>"", "mobil_visibility"=>"0", "fax"=>"", "fax_visibility"=>"0", "mail"=>"", "mail_visibility"=>"0", "id"=>"15"}}, "commit"=>"Verein speichern", "id"=>"17"}
顯示你的整個'params'散列。 –
def set_stored_with_own_address在哪裏?它能看到參數嗎? – Will
添加信息。 – Gerrit