More rails

Spend a few minutes searching for a nice autocompletion solution. Spent a few more minutes to read the various ways people recommend installing JQuery. Finally, someone recommends the jyquery-rails gem, which already is installed in rails4. Thanks. For nothing.

Finally, I settle on scoped_search. It seems pretty powerful and complete. It is also used by the foreman. Following the tutorial on the example application, it is quite easy to get this running.

Rendering fragments

Another issue I’d like to address is updating pages in situ, that is without a full reload. Github has implemented partial reloads with PJAX. This looks really nice, but I think, I’ll keep this complexity out of the code-base until I really need to squeeze out the last bit of responsiveness.

More testing

After reading too much about testing in rails, I’ve come to realize that all the cool guys use rspec-rails with a boatload of tools. Rails by default gives you MiniTest, which has no integration with guard. Good that I’ve not really have coded any tests yet. Let’s follow the rspec-rails intro for a while and see how that works out. Commit. Wow. Had to re-do almost everything since the scaffold generator stomps all over. It brings many tests in the default scaffold. And they guided me to fix them as required for the sorcery changes. Looking at codeclimate, I see a new issue: the scaffold’s default response blocks for save and update are similar and complex enough, to push the whole PeopleController down to a C. Also, code coverage slipped down another percent point, since the tests require valid and invalid attribute examples, which I haven’t yet provided. Adding those lead to a significant improvement in test coverage (35% to 85% for the controller). The only untested code is the scoped_search integration, which - like the duplicate default responses - should be extracted into a separate concern/aspect thingy.

Updating the project scaffold was comparatively easier, since the project has only a single field currently and I already knew what I was doing.

On the codeclimate side, this raised the coverage above 90%, but added even more complaints about the duplicated code. Not amused.

Still unsolved: HABTM editing

I spent again a good time with uncle Google but still no luck on a good two-list control to edit the N:M relation for big Ns and Ms (bigger than, say, five, which could be easily handled with checkboxes).

Interlude

I need to add some db:seeds, because entering new People by hand is really a drag. Done.

The Plan

Since search and autocomplete already works for People, I’m gonna implement this next for projects. Done.

Now I need a searchbox-plus-result-list-chooser control. That can chain up to a controller action that adds a specified Person to a Project (or vice versa). Fragment rendering’s sweet siren call is playing in the background.

I finally implemented a quite primitive post-back solution. As long as the responsiveness is good, it works Good Enough for now.