Alex_P
(Alex P.)
1
I want to set import_id
of one category manually, to be able to import remaining topics from an old forum.
I tried this in rails c
but it does not seem to work:
[11] pry(main)> Category.find(3).custom_fields
=> {}
[12] pry(main)> Category.find(3).custom_fields['import_id'] = '50'
=> "50"
[13] pry(main)> Category.find(3).custom_fields
=> {}
1 Like
pfaffman
(Jay Pfaffman)
2
I think you need to do something like
CategoryCustomField.create(category_id: 3,...)
Look at the code in the importers for an example.
2 Likes
Alex_P
(Alex P.)
3
Yeah, finally found it.
new_category.custom_fields["import_id"] = import_id if import_id
new_category.save!
So looks like I just need to call save
I got confused because for SiteSetting
it is not needed.
[14] pry(main)> c = Category.find(3)
=> #<Category:0x000056548fd948a8
id: 3,
...
[15] pry(main)> c.custom_fields['import_id'] = '50'
=> "50"
[16] pry(main)> c.custom_fields
=> {"import_id"=>"50"}
[17] pry(main)> c.save!
=> true
[18] pry(main)> Category.find(3).custom_fields
=> {"import_id"=>"50"}
2 Likes
system
(system)
Closed
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.