Ruby, JavaScript
Have you ever had to implement a search page for your client? I did and I’ve gotta say it’s often one of the most boring tasks. Not always, but often. There is a big list of features that the client usually expects other similar pages have. Especially when it comes to e-commerce websites. It needs to be fast, it needs to allow filtering, grouping and limiting by various attributes. On the backend side that usually means building sophisticated SQL queries, which is never a fun task when the search is highly dynamic and based on a variety of options available in the UI. Alternatively, you can use ElasticSearch or Lucene/Solr, but I’ve realized that while they are often super fast there is a lot of quirks that you need to learn when you would like them to just work.So, on one hand, there is all this complexity and challenge which you might like as a developer. On the other hand, there is rarely anything novel about the task of building a search page and you might feel de
Around a month ago, I worked on a task, which required a more dynamic frontend behavior. I worked on a component with 2 selects and 2 date pickers and depending on what was selected where the other pickers or select inputs had to be updated based on some relatively simple business rules. I decided to implement it using React.js and it was fun and pretty straight-forward to finish it. Also, working with http://airbnb.io/react-dates/ turned out to be a very pleasureful experience. But that’s not what this post is about.I wanted to test my component. The integration between Rails asset pipeline (which you can find in almost all legacy Rails apps) and Webpack (which is what anyone wants to use nowadays) is called Webpacker . Thanks to it you can organize, manage, compile your new JavaScript code with Webpack and have it nicely integrated into whole Rails app deployment process. For testing, I wanted
Process Managers revisitedI’ve been telling my story with process managers some time ago . In short I’ve explored there a way to source state of the process using nothing more but domain events. However I’ve encountered an issue which led to a workaround I wasn’t quite happy about. With the release of RailsEventStore v0.22.0 this is no longer a case!Let’s remind ourselves what was the original problem to solve:[quote]You’re an operations manager. Your task is to suggest your customer a menu they’d like to order and at the same time you have to confirm that caterer can deliver this particular menu (for given catering conditions). In short you wait for CustomerConfirmedMenu and CatererConfirmedMenu . Only after both happened you can proceed further. You’ll likely offer sev
Sometimes when doing large refactoring or upgrades we would like to find places in the code for which <code>grep</code> or Rubymine search is not good enough. These are usually cases where you would like to use something more powerful. And we can do that.I am upgrading this old app to Rails 4.1 and the <a href="http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#usage-of-return-within-inline-callback-blocks" rel="nofollow">official guide mentions this case</a>:<blockquote>Previously, Rails allowed inline callback blocks to use return this way:</blockquote><code>class Model < ActiveRecord::Base before_save { return false }end</code><blockquote>This behavior was never intentionally supported. Due to a change in the internals of <code>ActiveSupport::Callbacks</code>, this is no longer allowed in Rails 4.1. Using a return statement in an inline callback block causes a <code>LocalJumpError</code> to be raised when the callback is executed.</blockquote>Of course, the same code could look like:[code]class
We’ve already written in Arkency <a href="http://blog.arkency.com/2016/01/drop-this-before-validation-and-use-method/" rel="nofollow">a few times</a> <a href="http://blog.arkency.com/2016/02/using-anonymous-modules-and-prepend-to-work-with-generated-code/" rel="nofollow">about callbacks</a> <a href="http://blog.arkency.com/2016/05/domain-events-over-active-record-callbacks/" rel="nofollow">alternatives in Rails</a> and what kind of <a href="https://medium.com/planet-arkency/the-biggest-rails-code-smell-you-should-avoid-to-keep-your-app-healthy-a61fd75ab2d3" rel="nofollow">problems you can expect from them</a>. But I still see them being used in the wild in many scenarios so why not write about this topic a bit one more time with different examples.