noosfero | Migration to article invalid in Suggest Article (!1232)

Rodrigo Souto gitlab at mg.gitlab.com
Mon Jun 12 18:03:40 BRT 2017


Rodrigo Souto started a new discussion on db/migrate/20170607131552_update_suggest_article_data.rb:

> +class UpdateSuggestArticleData < ActiveRecord::Migration
> +  def change
> +  say_with_time "Updating suggest article datas..." do
> +    Task.all.each do |task|
> +       if task.type == "SuggestArticle" && task.data[:article].nil?
> +         data = task.data
> +         article = []
> +         article = {:name => data[:article_name],
> +                  :source_name => data[:source_name],
> +                  :source => data[:source],
> +                  :abstract => data[:article_abstract],
> +                  :body => data[:article_body]
> +                }
> +         task.data = {:article => article}
> +         task.save

Prefer using `save!` instead of `save`. `save!` will throw an exception if something goes wrong while `save` will only return false (which in this case will make no difference).

---
Reply to this email directly or view it on GitLab: https://gitlab.com/noosfero/noosfero/merge_requests/1232#note_32140580
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170612/c6b636b1/attachment-0001.html>


More information about the Noosfero-dev mailing list