Add Utils to your rails app
Github / Twitter
@jalkoby
There are many programming languages
&
we still use Ruby & Rails
From time to time
any rails developer looks
on an another solution
,
plays with it
&
comes back to Rails
The framework does the dirty work
&
introduces a lot of things that I has never thought about
The most useful rails parts
architecture & conventions
For more details watch a presentation about L ineman
http://www.confreaks.com/videos/3045-larubyconf2014-as-easy-as-rails
With a rails convention it's always clear where any part of code should be placed & named
but in every application there were a chucks of code which I didn't know where to put
Yes, it's not a terrible situation & you could live with it.
But there are a few problems
- with app growth a count of these chunks increases too
- some of them has a duplicated logic
-
it's harder to test it
They are good but your code becomes too much OO
&
gets a new problems with growth of files & classes
Welcome utils
- object in Scala
- namespaces(modules) in pure functional languages
- Ruby singleton without share state & complication in method accessing
A few lines to start using
As the result
-
get `helpers` but for all Rails application
- take benefits of a functional programming using Ruby
- avoid creating new instances of classes
- you know where to put not directly related "MVC" code
Use Cases
- generation collection for selects in view
- parsing common params in controllers
- other standalone stateless functions
QUestions?
Utils in Rails
By Sergey Pchelincev
Utils in Rails
- 1,831