-
Notifications
You must be signed in to change notification settings - Fork 526
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
Configure for use without ActiveRecord? #51
Comments
@realityendshere, I'm sorry you are having trouble with a NoSQL data source. I haven't done much testing with non ActiveRecord data sources. I think the problem is that the ResourceController requires the ActiveRecordOperationsProcessor by default. I probably need to make a few changes so that isn't loaded if you are not using ActiveRecord. I think the major change we need is to set an option for the OperationsProcessor in the configuration. Then have ResourceController.create_operations_processor use this to load the appropriate OperationsProcessor. I'll see if I can get to that soon, or you are welcome to try and fix it yourself if you want. |
As a temporary workaround, I use the "plain" OperationsProcessor instead of the one for ActiveRecord: #config/initializers/jsonapi_resouces.rb
require 'jsonapi/resource_controller'
module JSONAPI
class ResourceController
def create_operations_processor
JSONAPI::OperationsProcessor.new
end
end
end I haven't gotten too deep into if or how well this works with associations or really anything beyond rudimentary CRUD operations on a couple of records. But having a running Rails app is a start. |
Even with the workaround, you get this error when validations fail. JSONAPI::Resource has ActiveRecord-based rescues in it: def _save
@model.save!
@save_needed = false
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => e
raise JSONAPI::Exceptions::ValidationErrors.new(e.record.errors.messages)
end https://github.com/cerebris/jsonapi-resources/blob/master/lib/jsonapi/resource.rb#L118 |
@bvandenbos This is true! See issue #127. |
Ah - didn't see that issue covered it already. Thanks! |
Was this handled by #192 ? |
The projects I've worked on in the last year have all used ActiveRecord. I hesitate to confirm the fix. But: I will close this issue. If there are still challenges using alternatives to ActiveRecord, please feel free to comment. |
In experimenting with this gem, I seem to run into trouble trying to use this with a NoSQL-style database instead of ActiveRecord. When trying to create new records with POST, I encounter the error:
Can the gem be configured to use alternative data storage strategies?
Thanks.
The text was updated successfully, but these errors were encountered: