rails new my_app -T -d postgresql
Add:
gem 'angular-rails-templates'
gem 'bower-rails'
# 'rails_serve_static_assets' is only for staging on Heroku, omit otherwise
gem 'rails_serve_static_assets', group: [:production]
gem 'angular-rails-templates'
gem 'bower-rails'
rails g bower_rails:initialize
asset 'angular'
asset 'foundation'
asset 'fontawesome'
bundle exec rake bower:install
cd app/assets/javascripts/
mkdir -p angular/{templates,modules,filters,directives,models,services,controllers}/
//= require jquery
//= require jquery_ujs
//= require angular
//= require foundation
//= require angular-rails-templates
//= require angular/app
//= require_tree ./angular/templates
//= require_tree ./angular/modules
//= require_tree ./angular/filters
//= require_tree ./angular/directives
//= require_tree ./angular/models
//= require_tree ./angular/services
//= require_tree ./angular/controllers
touch app/assets/javascripts/angular/app.js
var app = angular.module('app', ['templates']);
app.config([
'$httpProvider', function($httpProvider) {
return $httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
}
]);
app.run(function() {
return console.log('angular app running');
});
rails g controller example home
<div ng-app="app"></div>
root 'example#home'
'data-turbolinks-track' => true
touch local.proc
postgresql: postgres -D /usr/local/var/postgres
rails: bundle exec rails s
foreman start -f local.proc
rake db:create
http://localhost:3000
"angular app running"
@import "foundation/scss/foundation";
@import "fontawesome/scss/font-awesome";
@font-face {
font-family: 'FontAwesome';
src: font-url('fontawesome/fonts/fontawesome-webfont.eot');
src: font-url('fontawesome/fonts/fontawesome-webfont.eot?#iefix') format('embedded-opentype'),
font-url('fontawesome/fonts/fontawesome-webfont.woff') format('woff'),
font-url('fontawesome/fonts/fontawesome-webfont.ttf') format('truetype'),
font-url('fontawesome/fonts/fontawesome-webfont.svg?#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
config.assets.paths << Rails.root.join("vendor","assets","bower_components")
config.assets.paths << Rails.root.join("vendor","assets","bower_components","fontawesome","fonts")
config.assets.precompile << %r(.*.(?:eot|svg|ttf|woff)$)
config.angular_templates.ignore_prefix = %w(angular/templates/)
control + c
foreman start -f local.proc