
Rails 4.2.0 beta1: Active Job, Deliver Later, Adequate Record, Web Console - jyunderwood
http://weblog.rubyonrails.org/2014/8/20/Rails-4-2-beta1/
======
r-s
Rails gets a bit of negative press these days, but its nice to see the
framework moving forward. Rails is still a great choice for a large percent of
web apps. There is a fairly big community even in smaller cities, a very
complete framework, a large ecosystem of gems, open source and still
improving.

~~~
liamzebedee
Yes it is nice to see continued progress! Could someone explain to me what
this negative press is about? I understand that Rails and Ruby by default are
not as performant as Node/Go/the JVM but it supposedly functions quite well
for relatively large websites (~10K users).

~~~
dhh
Here are some Rails sites: Basecamp, Github, Shopify, Airbnb, Soundcloud,
Indiegogo. All have millions of users.

~~~
mattangriffel
Here's a list of about 35 popular Rails sites I've compiled:
[https://onemonth.com/ruby-on-rails-example-sites](https://onemonth.com/ruby-
on-rails-example-sites)

------
j4pe
I've been working on a Django project for the last few months. In past gigs
I've used Drupal, and even talked community with one of Drupal's corporate
overlords at Acquia. I enjoy working with Ember and follow its releases. But
I've never grinned and cheered for new features the way I do with Rails.

It took me a long time to realize that Rails' greatness isn't due to magical
omakase magic - it's the community DHH (and the core team) have built over the
years, and the strong product focus they've applied. Really impressive. Did
Torvalds work like this? Has anyone has studied or written about
organizational behavior in the open-source community?

------
aaronbrethorst

        Support for real foreign keys!
        addforeignkey/removeforeignkey are now
        available in migrations.
    

Awesome! Despite the naysayers, I still feel incredibly productive in Rails,
and am so happy it continues to improve.

~~~
mberning
Agreed. Having recently worked on an implementation using
nodejs/express/angular going back to plain old Ruby/Rails is very nice.

~~~
monsterix
Totally! And I sorely miss cool and helpful guys like Ryan Bates in the scene
lately.

~~~
eriktrautman
Chris Oliver's running some good-looking screencasts to fill those shoes:
[https://gorails.com/](https://gorails.com/)

~~~
monsterix
Thanks! Great to hear someone's taken up the good work.

------
resca79
Here a rails committer.

Rails is 10 years old and it has definitely changed the web development. But
the unnecessary controversy always seem the same of its first year.

While in the last 10 years, many people talking Rails does not scale and ruby
is slow, for many companies rails was and is a great "tool" to delivery great
web apps.

Thanks Rails

------
neya
There was a time when I used to advocate my fellow folks here at HN (and
possibly even reddit) to go for a framework built on faster languages like
GoLang or Scala or even using platforms like Node.js and avoid slower ones
like Rails. Now, it's time for me to apologize to the community for giving you
wrong advice [1]. Turns out I could never have been more wrong.

I wish I could write a long post describing each of the WHY's, but I'll be
more succinct, this time:

1)If you can throw money at something at something and scale, then you're as
good as gold. Rails allows you to do this. Oh, and supportive statements from
Pinterest guys on the same topic - [2].

2) The speed of a language has nothing to do with the success of your
business. NOTHING. You can go with the world's slowest language and still be
successful. Best example of this is Basecamp itself.

As a matter of fact, even many of the popular sites (heck, even popular porn
sites) still run on PHP (PHP was one of the slowest from the frameworks speed
comparison conducted by Techempower - [3]).

3) The actual thing you want to be able to do is quickly iterate on your
product and constantly have it evolve. This is only possible if you have a
complete framework that doesn't force you to re-invent the wheel. For example,
when I wrote a framework by myself in GoLang, Scala, I found myself focusing
too much on basic stuff like authentication, instead of focusing on the
features that are needed for the actual product.

4) (P.S this is my personal opinion) I've tried all major frameworks out there
and I've come back to Rails again. Why? Because its philosophy resonates with
me (yes, now it does). For me, the three most important elements for a
successful product are - Speed, Reliability, Consistency. Rails provides me
with all these three. (And please try Puma, it's pretty impressive!).

As for me, the ability to seamlessly integrate SASS, Compass and HAML (which
help me divide my product development time multiple folds) makes Rails a clear
winner for me. And now Active Job, Deliver Later, Adequate Record, Web Console
now make Rails much more complete than ever. (Thank you DHH!)

In the last 6 months, I've written 4 complete products for 4 different people
(one of them, being mine) that is well tested and works perfectly as intended.
Compare this to something like last year where I spent 2-3 months writing just
a single software product (for myself) while I was trying to use GoLang (<\-
or insert another faster language here) (because I also had to take care of
all the other things like Authentication, etc). The point is, ultimately you
want to run a successful business. And if you're worried if the slowness of
your language will hinder it's growth, then nope. That will not happen. I hope
this helps someone.

Cheers.

[1]
[https://news.ycombinator.com/threads?id=neya&next=6993616](https://news.ycombinator.com/threads?id=neya&next=6993616)

[2] [http://highscalability.com/blog/2013/4/15/scaling-
pinterest-...](http://highscalability.com/blog/2013/4/15/scaling-pinterest-
from-0-to-10s-of-billions-of-page-views-a.html)

[3]
[http://www.techempower.com/benchmarks/#section=data-r8&hw=i7...](http://www.techempower.com/benchmarks/#section=data-r8&hw=i7&test=json)

~~~
jrochkind1
My biggest frustration with Rails at the moment is maintenance of my Rails
apps.

Rails versions come out quickly, and old versions stop being supported. And
it's become a non-trivial part of my time running the treadmill of keeping all
my Rails apps up to date, along with compatible dependencies.

I realize this kind of goes with the program. Rails all-volunteer development
manages to produce a reasonably powerful and non-buggy product that for the
most part is constantly getting better; the cost of this is quick evolution
and a maintenance burden for users.

I don't think I'd like the tradeoff better choosing a less
mature/powerful/robust framework, but it is increasingly frustrating.

(The fact that some of the things Rails adds seem unfortunate to me
(turbolinks, spring), can add to my frustration too).

~~~
rhizome
What forms of software development _don 't_ involve maintenance and upgrades?

~~~
jrochkind1
It's a matter of degree. I have PHP apps which have run for years with minimal
hands on them. All they need is an upgrade to PHP, which sometimes doesn't
require touching the app source code at all, or sometimes requires relatively
minimal (compared to my rails experience) updates to the source.

(I still do not choose to write my apps in PHP. Also these PHP apps did not
use a Rails-like framework. If I were to do a big app in PHP again, I'd want a
Rails-like framework. And indeed I wonder how much that would increase my
maintenance costs.)

------
cpursley
Truly impressive. I'd also like to see the Rails team focus on Rails-as-API
for those of us who have moved on from the asset pipeline (splitting the
server side from client side).

It would be nice to have a "API only" flag option when generating a new rails
project. Something like: `rails new myapp -api`. This could keep Rails going
for another 10 years.

I'm looking into using Napa, a Grape based API framework, for the purpose of
Ruby server-side API apps:
[https://github.com/bellycard/napa](https://github.com/bellycard/napa)

(Napa is to Grape as Padrino is to Sinatra)

Related reading: [http://www.divshot.com/blog/opinion/every-web-app-is-two-
app...](http://www.divshot.com/blog/opinion/every-web-app-is-two-apps)

~~~
steveklabnik
> It would be nice to have a "API only" flag option when generating a new
> rails project.

This was rejected by core and turned into [http://github.com/rails-
api/](http://github.com/rails-api/) , which has had some maintenance issues,
but is getting back on track.

(see [https://groups.google.com/d/msg/rails-api-
core/8zu1xjIOTAM/1...](https://groups.google.com/d/msg/rails-api-
core/8zu1xjIOTAM/1OXeQxq11ysJ) . This is about AMS, but that's only because
updating rails-api itself should be easy, and I'm going to check it out as
well)

------
tvon
So GlobalID means instead of doing `SomeJob.enqueue(instance.id)` (and then
`Model.find(id)` in the job) you just do `SomeJob.enqueue(instance)`, and
presumably reference something like `object` in the job?

~~~
sync
We frequently ran into the issue of the object having been deleted while
sitting in the job queue, so Model.find(id) would blow up. I'd be curious to
hear if GlobalID did anything about that.

~~~
DouweM
We had a bit of a discussion about that, finally settling on adding
`rescue_from` which you'll know from ActionController and raising a
`ActiveJob::DeserializationError` wrapping `ActiveRecord::RecordNotFound`,
allowing you to handle this lookup failure however you see fit.

See the original discussion here:
[https://github.com/rails/activejob/issues/25](https://github.com/rails/activejob/issues/25)

The discussion was then continued here:
[https://github.com/rails/rails/pull/16485#discussion-
diff-16...](https://github.com/rails/rails/pull/16485#discussion-
diff-16273182), which is where the `ActiveJob::DeserializationError` comes
from.

------
gt565k
My biggest gripe about Rails are the model validations and DB adapters.

As someone coming from Django, I hate that I have to explicitly define db
related validations and catch exceptions thrown by postgres instead of it just
being handled by AR with the DB adapter based on the database constraints.

I love how Django handles that and I hope this finds its way into Rails one
day.

------
martijn_himself
Sorry to 'hijack' the thread but I was wondering, as a newcomer to Ruby and
Rails, what would be the best way to learn it? (without spending too much
money).

It seems to me because it is such a mature framework there are a lot of Rails-
specific techniques and components to learn, this seems quite daunting to me,
am I correct?

~~~
dankohn1
The Hartl book is considered one of the best introductions, and covers all the
major Rails features and conventions. It's free to read online, and there is
also great support for it via Stack Overflow.

[http://www.railstutorial.org/book](http://www.railstutorial.org/book)

~~~
mhartl
Thanks for the plug. Be sure to watch for an upcoming announcement, too:

[http://news.railstutorial.org/](http://news.railstutorial.org/)

The upcoming third edition, which I hope to start publishing soon in draft
form, is by far the most newbie-friendly edition yet. Indeed, it threads a
rare needle: it's both easier _and_ it covers more advanced material than
previous editions. (This includes a rewritten chapter on login &
authentication, an all-new section on image upload, and an all-new chapter on
account activation and password resets.)

------
bdcravens
Nice to see some of the features from better_errors make it in - I always
figured it'd just replace the standard exception page.

------
axx
You don't need to make everything scalable right from the start. If your
business is profitable you should have enough money to think about scaling
later.

To me, the possibility to iterate fast has a much higher priority than
thinking about scaling if i have a few or not that many customers.

Thinking about performance problems when you start your first project/startup
is like thinking about what to buy IF you win the lottery.

------
urs2102
<%= console %> is a godsend

~~~
andyl
I was able to run bash and vim inside the browser console. And Tmux. And I
could run vim inside of Tmux. Split windows, multi-tabs, htop. Guard, rspec,
pry-debugger. Everything worked.

WOW

------
_mikz
I'm quite surprised by removing `respond_with` to a gem.

~~~
mrinterweb
I'm pretty sure that 90% of my controller actions use respond_with. I don't
understand the desire to remove that from the rails core.

------
VeejayRampay
A big thank you to all the contributors who keep making Rails better and more
polished at each release. Rails 4.x is great.

------
rudimk
What's the difference between the Web Console in this release, and the IRB
console that comes with Better Errors?

~~~
mmanfrin
For one, web console is built in. Other than that, I imagine not much.

~~~
rudimk
I see. Should check it out, then.

------
boie0025
I'm excited for the ActiveJob abstraction layer. This means I can start
building things out for background work before even deciding what I want to
have handle them.

------
ffn
Oh God yes, at last, 4.2. Real foreign keys, active jobs, deliver_later, etc.
I guess it's true, Overlord DHH really does hear our prayers.

------
andyl
Just saw this in the release notes:

    
    
        The PostgreSQL adapter now supports the JSONB datatype in PostgreSQL 9.4+. 
    

Indexable/queryable JSON - so fantastic.

~~~
chancancode
Along with that, one of the hidden gems is that dirty tracking now detect
inline changes correctly. This means things like JSON/JSONB columns Just
Works™ out of the box.

~~~
jrochkind1
Nice!

I've been interested in real ActiveRecord support for Postgres hstore, in a
way that can do partial updates -- if only one key/value has changed, on save
an update would be sent to postgres for only that key/value. This matters for
concurrency issues where multiple clients may be accessing postgres and
modifying the same values.

Does anyone know if anyone has been working on that at all?

------
andyl
One of the things I like best is the pre-announcement that Rails 5 will be
built for Ruby 2.2. I appreciate the role that DHH and Rails play in keeping
the community moving forward.

~~~
joevandyk
Yes, this should clean up a ton of the code in rails. Can take use of
exception causes and all the other things.

------
shouldbeworking
will there be a 420 celebration when it comes out?

~~~
Eleopteryx
Well I'm glad someone beat me to making this kind of comment.

------
oliyoung
I love Rails, it's been my tool of choice for the last six years, but "Support
for real foreign keys!" shouldn't be a thing in a change-log in 2014.

~~~
sleepyhead
So you don't want support for real foreign keys?

~~~
anonova
He probably means that foreign key support should have been added in a far
earlier version of Rails.

------
jiggy2011
"Adequate Record" does not exactly fill one with confidence regarding rails.
This says "our last versions had inadequate performance,this one is just ok"

~~~
chancancode
Sorry you felt that way. That project was sponsored by
[http://adequatehq.com/](http://adequatehq.com/), so we don't really have much
controll over that. Try emailing their marketing department maybe?

~~~
jiggy2011
Oh, this reminds me of that Bill Hicks clip.

------
j-kidd
I feel rather underwhelmed by the performance improvement touted by adequate
records. Perhaps someone from the rails community can do something like this:
[http://techspot.zzzeek.org/2010/12/12/a-tale-of-three-
profil...](http://techspot.zzzeek.org/2010/12/12/a-tale-of-three-profiles/)

~~~
mmanfrin
100% speedup is underwhelming?

~~~
jrochkind1
100% speedup to certain queries, not all queries. How many queries it covers
will depend on the app; as well, of course, how much of app wall time is taken
up on queries.

I too am curious how noticeable an improvement this will be in most apps. Is
it a micro-optimization that won't be noticed much, or is it actually going to
make a difference for real apps?

~~~
jrochkind1
(And the queries that are speeded up by this optimization are probably the
_fastest_ queries in your app to begin with--simple one column lookups on one
table, including probably most commonly lookups by pk. I am definitely not
assuming this will make any measurable performance difference to real world
apps. Although it may. I don't know if anyone knows yet.)

~~~
j-kidd
Also from
[http://stackoverflow.com/a/16553503](http://stackoverflow.com/a/16553503) by
the author of SQLAlchemy:

> Do you have any estimates on how much time is wasted, compared to the rest
> of the application? Profiling here is extremely important before making your
> program more complex. As I will often note, Reddit serves well over one
> billion page views a day, they use the SQLAlchemy Core to query their
> database, and the last time I looked at their code they make no attempt to
> optimize this process - they build expression trees on the fly and compile
> each time.

