New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using ActiveRecord in a stand alone script can't update the value #3635
Comments
|
It works well on sqlite3. Unfortunately I don't have mysql installed currently to check it. |
|
Guys can you confirm this issue?? |
|
you can try to reproduce the issue by the mysqldump file and the ruby script. |
|
Do you know if this still happens on 3.2? I don't have MySQL installed at the moment, if you can't check it out, I'll install it and give it a go. |
|
I tried to reproduce this today, and this is what I got: If I comment out the reload and the This is with Rails 3.2.8. So it would appear that this is an issue, yes. @jonleighton @tenderlove any thoughts? |
|
I don't think this is an issue. I guess the problem is that the strings are modified in place using # -*- coding: utf-8 -*-
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Schema.define do
create_table :answers do |t|
t.text :content
end
end
class Answer < ActiveRecord::Base; end
Answer.create! content: "Some Content "
Answer.find_each do |answer|
str = answer.content
str.strip!
# str = str.strip # this works
answer.update_attributes(:content => str)
endIf you use |
|
I'm closing this issue because I don't think it is a bug. @Zhengquan If my previous response was not the source of the problem, please comment and I'll reopen. |
The former talks about this issue can be found at StackOverFlow
I used ActiveRecord in a stand alone script without rails runner.
The Environment is listed below.
Source Code:
The table answers only has one record,the table dump file is pushed here.
Mysql Dump File
Prbolem
When I only use update_attribute, It can't update the record.
But when I replace this line with
answer.reloadanswer.update_attributes(:content => str)It indeed can update this only one record.
Is it a bug in ActiveRecord when using it stand alone.
The text was updated successfully, but these errors were encountered: