RoR: first_or_initialize block doesn't save
I have the following code, which works fine with no errors but the models
never get saved...
myarray.each do |item|
r = MyModel.unscoped.where(:site_id => @site.id, :url =>
item['permalink_url']).first_or_initialize do |r|
r.title = 'asdasdadaddjfgnfd'
r.save!
end
end
Terminal shows the SQL SELECT statements when attempting to find the
Models, but the UPDATE/INSERT statements never run.
What am I missing here?
No comments:
Post a Comment