How can I fill some database field with value, returned by mysql function?
In Yii(PHP) I wrote something like
$post->my_time=new CDbExpression(‘NOW()’)
How can I do that with Rails 3 ActiveRecord?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can get the result of a MySQL function with select_value
Or you can run
update()to store the value directly.But it’s generally not recommended to use complex database logic with ActiveRecord.