Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

colindensem/demo-rails-angularjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to DEMO Rails AngularJS

The intention of this project is to connect rails with Angular JS. AngularJS to replace the traditional rails view layer. Rails could of course be any API service, sinatra etc. I’m using rails as I know it (kind of) and it makes backend tasks easier, like email porocessing, queues and so on.

Some aims/thoughts

Rails serves json via api’s, possibly looking at Grape. Lean on Rails comfort for server tasks, e.g. email, workflow, db access and so on. Lean on the asset pipeline to comine and minify. Which requires:

Embedding angularJS within the assets.

Aiming to use an organisation by modules and not layers. Appears difficult to achieve, layers works and it’s in keeping with Rails, even if it’s not where I’m at…

Alternatives to the asset pipline would be to utilise the likes of grunt and yoman. These tools can manage the angularJS app outside of rails, but compile into the public dir. This would then be easy when sat behind the likes of nginx.

Pros:
    Also convienent to pass AngularJS app to non rails developer.
Cons:
    Another component to manage and possibly CORS.

Or rather:

avoid learning node as a json api server
avoid 2 seperate applications
avoid cross domain requests

There are a number of ways to do the above, there are some points, where I’m not even certain if the approach is right, but it’s a path…

Getting Started

  1. Should be viable to clone, migrate and then launch local server. All requests should invoke the home.index which really hands off right away to Angular.

With thanks

To the many people who have blogged about AngularJS and those who’ve listened to my questions.

I’d like to thank:

The guys behind angular-app, https://github.com/angular-app/angular-app. It's a cracking reference app and I've leant on it heavily.

Nils of http://nils-blum-oeste.net/ for a collection of vital articles on token_auth wrapping.

Description of Contents

The basic goal is a rails 3.2 app, with devise, active_admin, bootstrap, angular and api services (public and auth’d with token_auth).

The initial and relevant directory structure of this application is:

|-- app
|   |-- admin
|       |-- admin_user.rb
|       |-- dashboard.rb
|       |-- site.rb
|       `-- user.rb
|   |-- assets
|       |-- images
|       |-- javascripts
|           |-- active_admin.js
|           |-- app
|               |-- app.js
|               |-- assets.js.erb
|               |-- controllers
|                   |-- app_ctrl.js
|                   `-- info_ctrl.js
|               |-- controllers.js
|               |-- directives.js
|               |-- filters.js
|               `-- services.js
|           `-- application.js
|       |-- stylesheets
|           |-- application.css.scss
|           `-- overrides.css.scss
|       `-- templates
|           |-- info.html
|           `-- login.html
|   |-- controllers
|       |-- api
|           `-- v1
|               |-- info_controller.rb
|               |-- sessions_controller.rb
|               `-- sites_controller.rb
|       |-- application_controller.rb
|       `-- home_controller.rb
|   |-- helpers
|      `-- application_helper.rb
|   |-- mailers
|   |-- models
|       |-- admin_user.rb
|       |-- site.rb
|       `-- user.rb
|   `-- views
|       |-- home
|           `-- index.html.erb
|       `-- layouts
|           `-- application.html.erb
|-- public
|   |-- 404.html
|   |-- 422.html
|   |-- 500.html
|   |-- favicon.ico
|   `-- robots.txt
`-- vendor
    |-- assets
        |-- javascripts
            |-- angular-resource.js
            |-- angular.js
            |-- jquery.js
            |-- ui-bootstrap.js
            `-- ui-bootstrap-tpls.js
        `-- stylesheets
    `-- plugins

About

Sample app testing some ideas, it might not always work!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published