tweak 1: Make some column quick-editable on the index list page
Ok… so I want to be quickly able to edit few names, here on the same list page, something like below
Thats simply great!
Now it makes me quickly update any name there itself on the list page, <enter> will make it, <escape> will ignore it, and <tab> will move to the next one. awesome.
And to make it work I just need to have one line of code change
All I need to say is `editable_test_column`, and its done.
And here how it works, you will need to define a couple of things
You need to define editable_text_column, this you could place inside app/admin/lib/
and some css stuff
Next, I would love to quickly alter article type say having a dropdown there to save my time
tweak 2: quick editable dropdowns on list page
Ohh, now this is again great! … no? It actually updates the article type on value change. nice.
Let see the code behind
and to define `column_select`
CustomHelper is one of my helper modules that really helps me render dropdown the way I need, and provides me some nice options, one may choose to use the default rails select helpers
I do have worked out several more tweaks like toggle button for boolean column, show/hide columns on the list page, auto-populate/suggest feature for string filters, one can make use ActiveAdmin icons too, then for one of my requirements I have set up the whole custom header and a dozens of custom pages. I would easily say that ActiveAdmin is just simple and awesome, one can really customize it to the extreme, the code structure will allow you to imagine and implement a number of custom scenarios.
I often thought of this, application user is actually modifying the email contents before mail gets delivered. And I just set one example of it
Working with chef resource deploy, faced several issues with Git provider, for examples
- enable_submodule does not work properly
- it does not get the latest code from submodules
- it does not allow you to choose specific branch and sha of any submodule
- in fact for main repo it does not allow you to switch to any specific branch and sha
- for some reason it says branch=version, who knows why ….
I tried correcting all above, and below is one of my examples, its working for me
How much watts we do consume per cycle? Have we joined any of the green innovations like for instance green button. It would be great to know how much watts my house consumed this cycle, will I be able to reduce it, any one out there to help me reduce it. I have so many appliances running at home and I do have a smart meter measuring how much has been consumed. Would you also want to know how does meter measure your watts consumed, and how smart meters provide data for further calculation of your electricity bills.
There are several initiatives taking place in US, PlotWatt, FirstFuel and more, and they help you know your own detailed energy usage, along with other features like calculations, helping you out choosing right pricing plan, giving you several suggestions on how could you reduce your consumption and electricity bills.
Okeh, so this was a quick about Green Button.
Working on one of such initiatives, I came across to define a solution that will enable users to see what electricity bill they would end up paying if they apply some different pricing plan, hence ability to apply different pricing plans against the data consumed for the current or past cycles and being able to compare plans. Rather this would actually help utilities defining their trial plans.
Being rubiest for now more than 5 years, it immediately struck me about having a nice ruby DSL for this one, which could be easier to extend for new rules or sub-requirements. And this was a too much of excitement for me. Writing DSL gives you opportunities to play around ruby mixins, better modeling your classes, modules, beautifully engaging them with each other to work for us and present a nice output.
But there was a bad news for me, team decided to do this in python :( … though still I am to design and develop it.
Not having much exposure to python, having my ruby design plan ready on my mind, I started looking similar python capabilities, parsing, meta-programming, DSL models and more, team as well decided an approach that no need admin to define plans on the fly( like one above), but we could have some fixed plans defined, that actually saved my efforts.
Following is one example of one of those plans we have,
And we do have several such plans and we could define more, simply focusing on plan rules. The guts have been encapsulated using classes Plan and Calc. Calc helps to collect, compute usage for the specified period, while Plan provides semantics around.
I did enjoy python scripting a lot, python looks to me as a raw scripting platform where ruby as a very nice, user-friendly scripting platform.
Taking care of concerns, my views are
They are meant not to have large/GOD classes
They are not specific to ActiveRecord
They are there to help us out find out dependencies easier
They should not be dependent on each other, if module A has concern :b, then there should exist paths “root/a.rb” and “/root/a/b.rb“. Though this we ourself have to make sure about concerns path by writing additional code at initialization
I always willing to write clean and neat code, and have end up maintaining my concerns the following ways
- Reopening Class
- Include Module
- Extend ActiveSupport::Concern
I do have one doubt though, out of 3 approaches, which one is good for faster execution?