モデルを更新しない datamapper に問題があります。問題なくモデルを作成して保存できます。raise_on_save_failure
の戻り値を有効にして確認しましたupdate
が、エラーは表示されません。
モデルは次のとおりです。
class UserProfile
include DataMapper::Resource
attr_accessor :id, :wants_hints, :is_beta_user
property :id, Serial #auto-increment integer key
property :is_beta_user, Boolean
property :wants_hints, Boolean
has 1, :user, :through => Resource
end
そして、コントローラーで更新される場所は次のとおりです。
if user = User.get(request.session[:user])
if request.params[:user_profile]
beta = request.params[:user_profile].has_key?('is_beta_user')
hints = request.params[:user_profile].has_key?('wants_hints')
user.user_profile.update({:is_beta_user => beta, :wants_hints => hints}) # returns true
Log.puts user.user_profile.errors.each {|e| Log.puts e.to_s} # returns empty list []
end
end
コントローラーが呼び出されると、update
常に true が返され、エラー リストにエラーが表示されることはありません。に設定されている datamapper ログには、 andを取得するためのクエリ:debug
のみが表示され、それだけです。新しく作成されたモデルにアクセスできるのに、同じモデルにアクセスできないのはなぜですか?SELECT
user
user_profile
save
update