Closed schlos closed 4 years ago
Hmm strange this came up at https://groups.google.com/forum/#!topic/alaveteli-dev/YoOrH_qVDxc. Plz to comment there if you find a fix before us!
Issue has been resolved with solution shared by Alaveteli Dev team on AlaveteliCon 2019:
It's same issue as Elenor's issue: https://groups.google.com/forum/m/#!topic/alaveteli-dev/YoOrH_qVDxc
Reproduce with:
AlaveteliLocalization.with_locale('sv') { PublicBody.where(url_name: 'internal_admin_authority') }
where sv
is your site locale.
So this appears to be a issue with Rails <=4.2 which is why we couldn't reproduce on WDTK with Rails 5
Check your Internal Authority body (run in Rails console):
PublicBody::Translation.where(url_name: 'internal_admin_authority').where.not(locale: AlaveteliLocalization.default_locale)
Possible quick fix (run in Rails console):
PublicBody::Translation.where(url_name: 'internal_admin_authority').where.not(locale: AlaveteliLocalization.default_locale).destroy_all
<< be careful about running this!!
After migration same issue was reproduced:
A RuntimeError occurred in public_body#list:
Multiple public bodies (2) found with url_name 'internal_admin_authority' app/models/public_body.rb:390:in `internal_admin_body'
Database:
SELECT * FROM public_body_translations WHERE url_name = 'internal_admin_authority';
id | public_body_id | locale | first_letter | request_email | publication_scheme | notes | short_name | name | url_name | created_at | updated_at | disclosure_log
-------+----------------+--------+--------------+--------------------------------+--------------------+-------+------------+--------------------------+--------------------------+----------------------------+----------------------------+----------------
6 | 1 | hr | I | REDACTED | | | | Internal admin authority | internal_admin_authority | 2015-02-21 12:46:38.527393 | 2015-02-21 14:18:53.037204 |
34547 | 1 | en | I | REDACTED | | | | Internal admin authority | internal_admin_authority | 2019-10-13 06:23:40.211418 | 2019-10-13 06:23:40.211418 |
(2 rows)
After running in rails console:
PublicBody::Translation.where(url_name: 'internal_admin_authority').where.not(locale: AlaveteliLocalization.default_locale).destroy_all
Result in db:
id | public_body_id | locale | first_letter | request_email | publication_scheme | notes | short_name | name | url_name | created_at | updated_at | disclosure_log
----+----------------+--------+--------------+--------------------------------+--------------------+-------+------------+--------------------------+--------------------------+----------------------------+----------------------------+----------------
6 | 1 | hr | I | REDACTED | | | | Internal admin authority | internal_admin_authority | 2015-02-21 12:46:38.527393 | 2015-02-21 14:18:53.037204 |
(1 row)
Actual behavior
[ERROR] [imamopravoznati.org] public_body#list (RuntimeError) "Multiple public bodies (2) found with urlname 'internal...
Steps to reproduce
Go to http://www.imamopravoznati.org/en/body/list/o
Expected behavior
Should work