-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Migrating from rails 4 breaks the paths #3355
Comments
Hi @thebravoman ! Refinery should be mounted to work properly: Example: https://github.com/refinery/website/blob/master/config/routes.rb#L4 |
Initially I had it mounted with
but it does not work. So I thought of removing it from config/routes.rb and it still does not work. That's what I mean that even after just adding to the Gemfile the error occurs. |
Setting
does not help |
This here is the reason:
Why are you overriding the default_url_options? I already have my own implementation of default_url_options. |
I have this configuration for i18n
but the call
return false. |
My understanding on default_url_options is to have the following implementation:
In this way when there is a locale it is set in the options for default_url_options. If there is no, then a locale of null is set. This make polymorphic_path works, because it will have a locale of nil. Otherwise if it has no locale the object in
is understood as a locale and the error below occurs:
Refinerycms should probably override default_url_options, but only if there is no currently implementation. Not doing it by default? What do you thing? @bricesanchez |
refinery/refinerycms-i18n@89dbd52 and it appear 1 month later in this commit : refinery/refinerycms-i18n@f61f58a#diff-78f6fc19856dc84d95f49a323a7a0735 It looks like it silently fail. Could you provide a bugfix? |
Here is an idea - do not change the default_url_options in the application controller. Something like the code below. Refinery should not make all the other engines and the main app stick to its implementation of default_url_options and this should somehow be controlled. Perhaps with an if?
|
@bricesanchez I would try for a bug fix, but I do not fully understand the bug. I do not understand why is refinerycms redefining a method that has a perfectly valid implementation for the container app and for the other engines. I am also not sure why is there a separate set of values ::Refinery::I18n.* that seems to do more or less the same as ::I18n.locale. Can't we just use the ::I18n.locale everywhere? |
For example for my case the bug fix will look like this: Initial:
Fixed - with locale: nil
|
Hi @thebravoman! Could you test this PR to see if it fix your problem: refinery/refinerycms-i18n#74 Just add this in your Gemfile, then bundle: gem 'refinerycms-i18n', git: 'https://github.com/refinery/refinerycms-i18n', branch: 'bugfix/default-url-options' |
Hi @bricesanchez, In the routes I have
This means that I will have an url
/courses and /en/courses are the same thing because the default locale is en. So the user should be directed to /courses instead of /en/courses when he is browsing the site. That's why we should return {locale: nil} when we are in the default locale. But there is another problem with that. If the develop wants to have the locale as a param at the end of the ulr than we have these cases:
If this is the case and we return locale:nil than the url for the default locale will be
In summary: The way I've implemented it is
but this works only for the case where the locale is not a param but is part of the path. |
This is what happens with my bugfix. I think we will need a spec to confirm the behavior. |
Here is my proof for the bugfix : #3356 |
I have an app using rails 4.2 and refinery working perfectly well. I've managed to upgrade everything to rails 5.1 except refinery.
After I add
to the Gemfile with nothing else
the following error occurs.
No route matches {:action=>"show", :controller=>"courses", :locale=>#<Course id: 5, created_at: "2017-08-01 17:12:55", updated_at: "2018-03-05 07:54:18", published_at: nil, picture_file_name: nil, picture_content_type: nil, picture_file_size: nil, picture_updated_at: nil, content_picture_id: nil, public_index_content: true, usage_type: "undefined", title: "Ddddldld">}, missing required keys: [:id]
The code is
Which means that the main_app is now refinery I've not even add the refinery to the routes. Just changed the version in the Gemfile.
The text was updated successfully, but these errors were encountered: