Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.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 RubyonRails更新属性未更新_Ruby On Rails_Ruby_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails RubyonRails更新属性未更新

Ruby on rails RubyonRails更新属性未更新,ruby-on-rails,ruby,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 4,我正在尝试通过以下方法更新当前用户的信息: current_user.update_attribute(:country, "") 但它没有更新任何东西。 当我在控制台里做同样的事情时,一切都很好。 请帮我解决这个问题?我猜它正在更新用户表中的记录,但请注意,它不会自动更改内存中记录副本中的属性 试试这个 current_user.update_attribute(:country, '') current_user.reload 尝试current\u user.update!(国家:)

我正在尝试通过以下方法更新当前用户的信息:

current_user.update_attribute(:country, "")
但它没有更新任何东西。 当我在控制台里做同样的事情时,一切都很好。
请帮我解决这个问题?

我猜它正在更新
用户
表中的记录,但请注意,它不会自动更改内存中记录副本中的属性

试试这个

current_user.update_attribute(:country, '')
current_user.reload

尝试
current\u user.update!(国家:)