Rails Missing Features
      We don't have all the answers
  but we definitely have some questions.




                            Boris Nadion
                            @borisnadion
Boris Nadion
developing software since early 90th
   working with Rails since 2005
         partner at Astrails
the greatest thing
programmer happiness
beautiful code
testing
community
the best developers community in the world
high quality code
 the community usually produces
opinionated
saves time
not making the same decisions over and over again
name tables
name controllers
put source files
test the code
queue
 Rails 4
etc
save time
http://www.flickr.com/photos/genista/929340935/
decisions
“static” pages
Privacy Policy, Terms of Services, About Us, etc
not static at all
customers what to change them from time to time
I don’t
basic CMS
not a full featured monster
too many choices
High Voltage
         Rails Engine for static pages
https://github.com/thoughtbot/high_voltage
Refinery CMS
An open source Ruby on Rails content management system
         https://github.com/refinery/refinerycms
BrowserCMS
    Humane Content Management for Rails
https://github.com/browsermedia/browsercms
ComfortableMexicanSofa
                  Rails 3 CMS Engine
 https://github.com/comfy/comfortable-mexican-sofa
another ~20 projects
      worth mentioning
it shouldn’t be a part of the framework!
why?
ERB
HAML
choice
ERB is a default
i18n
keeps the texts in separate YAML files
textile or markdown
basic CMS
CORS
Cross-origin resource sharing
server:
http://api.service.com   AJAX calls



                                 client:
                         http://example.com
Access-Control-Allow-Origin
Rack CORS Middleware
   https://github.com/cyu/rack-cors
JSON serialization
business logic
  should be in a model
as_json
class Meaning < ActiveRecord::Base
  has_many :senses

 AS_JSON = {
   only: [:id, :name],
   methods: [:voiceover_url],
   include: {senses: Sense::AS_JSON}
 }

 AS_JSON_SHORT = {only: [:id, :name]}

  def as_json(opts = {})
    super opts.merge(opts.delete(:short) ? AS_JSON_SHORT : AS_JSON)
  end
end

# controller

def index
  render(json: collection.to_json(short: true))
end
representation
   should be in a view
Jbuilder
https://github.com/rails/jbuilder
JSON Builder
https://github.com/dewski/json_builder
class MeaningsController < InheritedResources::Base
  respond_to :json
  actions :index
end

# app/views/meanings/index.json.json_builder

meanings collection do |meaning|
  id meaning.id
  name meaning.name
end
think
user authentication
OmniAuth
https://github.com/intridea/omniauth
Devise
https://github.com/plataformatec/devise
standard de facto
real time web
    server push
Push Technologies Overview
http://astrails.com/blog/2012/10/2/devcon-2012-real-time-web-slides
dumb server
no business logic, no persistence, direct relay
notify push server
Rails                                         push server




  create/update content                      send updates




client                                client
                                       client
                                        client
                                         client
                                          client
hosted solutions
pusher, pubnub, hydna, and others
channels and messages
pubnub = Pubnub.new(... keys and auth...)

pubnub.publish(
  message: "some-message, preferably JSON",
  channel: "some-channel-name, preferably secret token"
)

# somewhere on a client side ...

PUBNUB.subscribe({
  channel : "some-channel-name, preferably secret token",
  callback : function(message) {
    console.log("we've got a message", JSON.parse(message))
  }
});
config.push = :pubnub
config.push_auth = {...}

Rails.push.publish(channel: @post.token, json: @comment)

# somewhere on a client side ...

$(window).on("push", function(e, channel_name, message) {
  console.log("new message", channel_name, message);
});
pagination
will_paginate vs. Kaminari
infinite scroll
abstraction
a part of the framework
save a lot of time
     to spend it on...
http://www.flickr.com/photos/grandvelasrivieramaya/3179390917/
http://www.flickr.com/photos/cobalt/6162053776/
Thank you!
Slides and video will be published at
       http://astrails.com/blog




                           Boris Nadion
                           @borisnadion

Rails missing features