Action Cable is an awesome feature that uses Web Sockets to realise a real time application in Rails, and includes both the back-end and the front-end. In this article, we will use only the server side of Action Cable in Rails and client-side in AngularJS 1.x. This is not a step-by-step tutorial, but it is intended to help you to understand the purpose of each step.
The first thing we need to do is enable Action Cable in our back-end app. The simplest way is to mount action cable in the
Arrayisn't like your typical array: it's an object with keys that are indexes. What this means is that you need to be aware that the length can be more than the number of elements and that there can be "holes".
In day-to-day development you'll probably just build up arrays using the literal syntax, like so:
ES6 introduces the
classkeyword. At first glance this looks like a completely new object model that follows classical languages like Java or Ruby, but behind the new syntax there is nothing new. The
The Asset Pipeline (Sprockets) is the canonical way of packaging assets in Rails, it makes things very easy for us as it provides a very clear way on how to load our assets and how to bundle them for production.
I believe the Asset Pipeline is a good approach for most Rails applications, but there are times when it makes things harder and shows limitations.
Rails provides a very convenient way of sending forms via AJAX using the Rails UJS helpers e.g.
The last 5 years has seen an explosion of rich front-end applications (also referred as SPA - Single Page Application) and during this time I have had the luck of working on many projects like this.
I have worked on small single page apps and a few big ones too. Built with many different things like Adobe Flex, jQuery, Backbone, Angular, CanJS. Thus I believe I have a bit of experience to share.
In this code we expect to find an object in the
App.Vehiclenamespace, so obviously the code that defines
We all have to deal with timezones in our Rails app sooner or later (probably sooner). In this blog post I want to share some of the tricks I have learned to deal with timezones effectively in Rails.
Unless you are confident that you will never need to deal with timezones, you should think about them sooner rather than later, building your application in a way that accommodates for them from the beginning. This is one of those things that can be very difficult to include later, so I don't think it is a premature optimisation.
In this case the class
btn_viewis the hook that JS uses for listening to or manipulating the DOM. The choice of what to use for these hooks may seem inconsequential at first but it is an important decisions that can aid a lot with the maitainability of your application.
Face it, you are a top developer, one of the best at your game, you eat lambda's for breakfast, refactor whole apps as an afternoon snack and bad code just trembles when you approach. You are at the top of your game and nothing stands in between you and the code you desire. Yet, the Rails asset pipeline still trips you up, not once, not twice, but just about every time you try and use it.
Here's a list of things that I have learnt that aren't necessarily obvious, that can help you tame this wild and savage beast.