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.

  1. uninitialized constant ActionController::RedirectBackError

    No replacement afaik, you should use redirect_back method with fallback_location keyword argument. References.

  2. Returning false in before_save callback doesn’t halt it (old kinda specific Rails gotcha/behavior).

    As replacement you can just throw(:abort) in your callback method. References.

  3. NoMethodError: super: no superclass method xhr for RSpec::ExampleGroups::<controller>

    Rename xhr :post to post :create, xhr: true and you’re good to go.

  4. render nothing: true tries to render template

    Use head :ok (or other status you need). References

  5. ArgumentError: unknown keyword: <key>

    All extra params should be put under params key, so something like get :show, id: <id> should look like get :show, params: { id: <id> }

  6. No method error on object.errors.get(:field)

    Access errors via [] instead - object.errors[:field]