Angular + Rails – made easy



Angular + Rails – made easy

0 2


rails-n-angular-krug-09-07-2013

Angular + Rails

On Github wrozka / rails-n-angular-krug-09-07-2013

Angular + Rails

made easy

Pawel Pierzchala @zwrozka

Separation

Frontend and backend are independed applications

Communication

Through an API

Tips & Tricks

Security #1

$httpProvider.defaults.xsrfCookieName = 'X-CSRF-Token'
$httpProvider.defaults.xsrfHeaderName = 'X-CSRF-Token'
cookies['X-CSRF-Token'] = form_authenticity_token

Security #2

PREFIX = ")]}',\n"

def render_json(data)
  json = PREFIX + data.as_json
  render text: text, content_type: "application/json"
end

JSON conventions

{ userName: 'Joe' } == { :user_name => 'Joe' }

HTML files in assets pipeline

Testing in Ruby

API request specs / unit tests

Testing in JavaScript

Unit tests with Karma

Acceptance tests

In Capybara

end to end (api)

A word on Angular guts

Without any race conditons in pure angular

Almost no problmes with JavaScripts from ngmodules.org

Old Capybara tricks as fallback

Mock api

Record & Playback

Summary

independed applications

stable e2e tests

links

Thanks