Skip to content
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

Db migrations fail with the refinery4-compatible branch matho-update #171

Open
jussihirvi opened this issue Sep 15, 2020 · 1 comment
Open

Comments

@jussihirvi
Copy link

jussihirvi commented Sep 15, 2020

I installed this gem for my refinerycms 4.0.3 app (with Rails 5.1) from the matho-update branch:

gem 'refinerycms-news', github: 'refinery/refinerycms-news', branch: 'matho-update'

In general, it was a good experience. However, the first migration failed with a message:

== 20200915155938 CreateNewsItems: migrating ==================================
rails aborted!
StandardError: An error has occurred, all later migrations canceled:

[FriendlyId] You need to translate the 'slug' field with Mobility (add 'translates :slug' in your model 'Refinery::News::Item')
/usr/local/rvm/gems/ruby-2.5.7@refinery403/gems/friendly_id-mobility-0.5.4/lib/friendly_id/mobility.rb:35:in `advise_against_untranslated_model'

In fact the model already contains translates :slug. I checked that by overriding the model first.

Anyway, I could run the migrations successfully after temporarily commenting out the function advise_against_untranslated_model in the friendly_id gem.

First I thought the error is raised because the field slug is not yet added to the table in this first migration, but only in a later migration. But it is not that simple. I rolled back all ten migrations, added the field slugto the create tablestatement of the first migration, and tried to migrate again. Still I got the same error.

BTW, in the rollback of the create table migration, ::Refinery::UserPlugin was not found, and also this gives an error (because delete_all does not take parameters):

::Refinery::Page.delete_all :link_url => "/news"

So I edited it to

::Refinery::Page.where(link_url: "/news").delete_all
@jussihirvi
Copy link
Author

The same error (You need to translate the 'slug' field with Mobility) appeared again when I visited /refinery/news/items on my site. The error went away when I edited this line in the refinery/news/item model:

friendly_id :title, :use => [:slugged, :mobility]

into this:

friendly_id :title, use: :slugged

I already use mobility anyway for translations. I did not find any documentation for using :mobility like that with the friendly_id command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant