Skip to content

Instantly share code, notes, and snippets.

@3014zhangshuo
Created August 2, 2018 02:51
Show Gist options
  • Save 3014zhangshuo/6c55feb9b1b0e3b0716119a2aa929aef to your computer and use it in GitHub Desktop.
Save 3014zhangshuo/6c55feb9b1b0e3b0716119a2aa929aef to your computer and use it in GitHub Desktop.
Dynamic set object attributes
a = Article.find(3)
a[param] = "value"
a.save
# or
a = Article.find(3)
a.send("#{param}=", "value")
a.save
# or
update_attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment