-
Notifications
You must be signed in to change notification settings - Fork 227
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
[RFC] Remove dependency on view_context #288
Comments
cc @ajahongir |
Oh, this is an important change... I have a question: are you sure that Draper are still updated? Don't see a lot of activity in that repo. |
I believe going this way, you should bump to as for:
You don't need a project to have (code) activity every so often, IMHO, you only need a stable project. These are (literally) my two cents 🙂 |
It sounds good and totally agree with @antillas21 to bump up 1.0 release |
Hi!
Actually Draper is an optional dependency and will not be installed by
Also
I agree that at some point we should bump to 1.0 but I'd love to fix #228 and some other issues before releasing a 1.0. The goal is to have a stable API for the 1.0 release. I don't know yet how solving #228 would impact the API. Thus the 0.5 release. |
And thanks everybody for your answers :) |
Hi there! After a lof of thinking on how solve this #228 I came with some solutions. The ORM module should be included in the To solve the "extend at runtime" issue we can :
It also removes the need to configure the ORM (a bit of convention over configuration). Notes: I've already thought of dependency injection but it's not doable due to the current implementation : https://github.com/jbox-web/ajax-datatables-rails/blob/master/lib/ajax-datatables-rails/orm/active_record.rb#L27. def initialize(params, opts = {})
...
@orm = opts.fetch(:orm, ActiveRecord.new(self))
end but how do you do : orm = Mongo.new(dt)
dt = PostDatatable.new(params, orm: orm) Or we can just inject the class name and call On the other side it would make cleaner "interfaces" and responsabilities between objects... I tried both :
|
Finally the "injection" solution doesn't solve the very first issue : "Allow again overriding filter_records, sort_records" so it's a no go :) |
Hi there! Any thoughts on the last proposal? ( |
Release 1.0.0 is out! https://github.com/jbox-web/ajax-datatables-rails/releases/tag/v1.0.0 |
Hi there!
In order to have a cleaner API for
ajax-datatables-rails
and in a long term view for this gem, I'd like to remove theview_context
dependency by directly injecting theparams
hash.It would have some advantages :
ajax-datatables-rails
would be compatible with Rails API which doesn't haveview_context
(Using in API only mode? #240)view_context
is a quite big object to pass around, passing a hash would be lighterBut it also have some drawbacks :
view_context
from within the datatable. (as in https://github.com/jbox-web/ajax-datatables-rails#using-view-helpers), but you can use Draper which is IMHO a much cleaner implementation for this.ajax-datatable-rails
)If you really want to inject the
view_context
as before you can still use theoptions
hash :I'm testing this idea on a real world application (45 datatables) with this branch : https://github.com/jbox-web/ajax-datatables-rails/tree/feat/rails-api and so far it works very well :) (I made the migration on Draper before)
Tests are passing : https://travis-ci.org/jbox-web/ajax-datatables-rails/builds/375203557 🎉
The idea was a lot inspired by Trailblazer which I use in my app 👍
What do you think? It would be for a
0.5
release.The text was updated successfully, but these errors were encountered: