Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Nov 3, 2025

Prior to this commit, incomplete class-level configuration would raise errors unrelated to the missing values.

For example, the following error is raised when executing .find without first setting .site on the resource class:

NoMethodError: undefined method `path' for nil

Similarly, .collection_url and .element_url invocations raise a similar error:

bad argument (expected URI object or URI string)

This commit improves the error messages raised when attempting to use an ActiveResource::Base subclass that hasn't yet been configured with a .site class attribute.

The Missing site URI message raised as an ArgumentError mirror the one raised by ActiveResource::Connection#initialize.

Prior to this commit, the following error is raised when executing
`Base.find`:

```
NoMethodError: undefined method `path' for nil
```

Similarly, `.collection_url` and `.element_url` invocations raise a
similar error:

```
bad argument (expected URI object or URI string)
```

This commit improves the error messages raised when attempting to use an
`ActiveResource::Base` class that hasn't yet been configured with a
`.site` class attribute.

The `Missing site URI` message raised as an `ArgumentError` mirror the
one raised by [ActiveResource::Connection#initialize][].

[ActiveResource::Connection#initialize]: https://github.com/rails/activeresource/blob/v6.2.0/lib/active_resource/connection.rb#L34
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

Successfully merging this pull request may close these issues.

1 participant