background preloader

Rails/Angular - Github, etc.

Facebook Twitter

A Proposed Pattern for Rails and AngularJS. Recently we have begun integrating the AngularJS framework ( into our rails applications to good effect.

A Proposed Pattern for Rails and AngularJS

They aren’t a true SPA (Single Page Application) but some aspects of them have lent themselves nicely to wrapping a section in Angular to basically handle the CRUD for a model etc. Why I Built an AngularJS Training Site on Rails. Photo Credit: Memotions If you’re into AngularJS at all, you are probably familiar with the kickass AngularJS video training from egghead.io.

Why I Built an AngularJS Training Site on Rails

If you haven’t seen egghead.io, it is a collection of 50+ short “bite-sized” training videos, largely focused on the AngularJS framework. The videos are created by (and feature) my friend John Lindquist playing Webstorm like a violin while explaining basic AngularJS concepts. Over the last few months John and I have been discussing egghead.io, and what its future holds. Automate your GitHub processes with botdylan. Liamneesonsarm. First Crud in Rails+Angular JS.

Get the whole code here: This a howto about how create your first R+AJS.

First Crud in Rails+Angular JS

AngularJS (AJS) is an Ecmascript framework that gives a further and deeper step into the DOM-Javascript merge. AJS is a bidirectional framework, this means that DOM elements and the Javascript code are under an uninterrupted communication and using the $scope object as the application "glue". This "magic link" will saves you many problems and will improve your productivity.

This more completes and advanced features are the reason of why AJS is chosen over another options as Backbone. As you can all starts with the classic: Git Workshop. AngularJS Tips&Tricks. Using AngularJS with a Rails backend - Emmanuel Oga's Software and Stuff. I created a sample AngularJSapp which uses rails as a backend.

Using AngularJS with a Rails backend - Emmanuel Oga's Software and Stuff

While it is possible to include AngularJS as part of the rails assets, I think it is better to setup the angular code base on a standalone folder, leaving the rails app as a (more or less) isolated backend. There are several advantages to this setup: Ability to manage the frontend app using Yeoman (including generators!). No more questions about file layout: use rails layout for rails stuff, angular-generator layout for angular stuff.Easily install external assets via bower (e.g. angularjs, jquery, twitter bootstrap, underscore, etc.).Write client side unit tests and run them with karma.Promotes unit-testing the js codebase and removes the temptation of integration-testing everything: testing with karma is a lot faster than using capybara or a similar solution.LiveReload support for free with yeoman's angular generator!

(uses websockets, no need to install a browser plugin). Yeoman, Bower, Livereload and Karma Runner. Deploying. The right way of coding AngularJS: How to organize a regular WebApp. Basic Example. Hey, I’ve been coding with AngularJS for some time.

The right way of coding AngularJS: How to organize a regular WebApp. Basic Example

I still like BackBone very much, but I’ve come to understand that BackBone is very simple and minimalistic. You gotta do most of the job, which is not very productive. AngularJS is a very productive framework that lets you organize the code if you know what you’re doing. However, it’s very easy to fuck it up and end with the same (or worse) spaghetti code that you wanted to avoid by adding and MVC (not really :P) framework. So, let’s get down to business. So, what would be a very good example of this. You go to the URL / and you get a page in the following way: Proposed Angular’s WebPage structure. Guideline on creating pages on AngularJS.

Proposed Angular’s WebPage structure

This applies for angularizing per page and not a SPA. Basic Structure The basic idea is to have one Main Controller which will have in the scope all the common models and functions that will be used troughout the entire page. In Angular, if you have a child controller, that controlller’s scope will use prototypal inheritance with the MainCtrl. This means that the scope of the child controller will have all the models and functions from the MainCtrl. Then, the page will have one controller per each main “view”. Inside each view, we’ll be using directives for the different components of the page. Reasons Using this basic structure, we leverage scope inheritance and binding to get things done. If we need to also be notified of this changes, we can use the $scope.

Learning Angular on Rails. Last night I had the best idea for a JavaScript framework.

Learning Angular on Rails

It was going to use the dom with data attributes in a totally unobtrusive way. It would have global repositories for remote data, do caching, and attach controllers to the dom automatically. This morning, I realized that's pretty much how Angular.js rolls, so I decided to learn the basics. Integrating Angular.js with Rails (Part 2) This article continues where the first article, "Integrating Angular.js with Rails" left off.

Integrating Angular.js with Rails (Part 2)

In this example we'll setup a client side app to display posts using Angular.js and ajax requests, served from a server side Rails app. Client Side Display Before we introduce the ajax, lets just hardcode the posts model data in a new Angular controller. Integrating Angular.js with Rails. Angular.js is an interesting client-side javascript MVC framework which makes use of directives, dependency injection, and data binding.

Integrating Angular.js with Rails

It does not require managing a central master controller or dispatcher. It promotes itself as the precusor of capabilities that'll be built directly into future browsers. I think it's cool, simple, and useful. RoR & AngularJS: Resources. I’m a huge fan of AngularJS and an even bigger fan of Ruby on Rails.

RoR & AngularJS: Resources

However, one of the gripes I have with AngularJS is the fact it lacks great documentation. Stuff seems scattered, especially when it comes to the magical ‘Resource’ module. To test the feasibility of AngularJS when using Rails I created a simple project to demonstrate an all AngularJS front-end communicating to a Rails back-end via the Resource module. The following write up starts with setting up Rails and moves into setting up Angular later. Source and Live Demo You can find the entire project here on Github and the live demonstration of the project here on Heroku .

On Github

Using AngularJS with Rails - NYC Meetup. Sending data from an Angular to create method in Rails controller. Mightygio.