After like 3 weeks of not touching code I decided to refresh my pet project a little bit, below are random issues you might encounter while trying to upgrade your old Rails 4 app to Rails 5.
uninitialized constant ActionController::RedirectBackError
No replacement afaik, you should use
redirect_back
method withfallback_location
keyword argument. References.Returning
false
inbefore_save
callback doesn’t halt it (old kinda specific Rails gotcha/behavior).As replacement you can just
throw(:abort)
in your callback method. References.NoMethodError: super: no superclass method xhr for RSpec::ExampleGroups::<controller>
Rename
xhr :post
topost :create, xhr: true
and you’re good to go.render nothing: true
tries to render templateUse
head :ok
(or other status you need). ReferencesArgumentError: unknown keyword: <key>
All extra params should be put under
params
key, so something likeget :show, id: <id>
should look likeget :show, params: { id: <id> }
No method error on
object.errors.get(:field)
Access errors via
[]
instead -object.errors[:field]