Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intergrating Angular JS with rails

I need some guidance to figure out how to incorporate Angular inside rails.

Reason for choosing Rails : I like their opionated approach to do things right. Also migrations, gems are really cool.

Reason for angular : I was researching and looking for framework best suited for SPA. Backbone seem too abstract. I had choice to make between Angular & Ember. I started reading Angular first and it made sense to me. So i never went to read about ember.

Reason for Angular & Rails: I researched and tried using small scale framework like grape, slim ( Yes i use php too ). But i feel need to stick to rails for long term scope of project. And personally i like doing things rails way.

So here is where i need help,

I have rails project in Rails 4.

Sign-in , sign-up everything is created as followed in Michael Hartl tutorial. Have tweaked stuff based on my requirement.

So post-sign-in or post-sign-up steps a view from show action of users controller is rendered.

I figured i'll need different layout files so i created same for outer pages and inner pages, respectively.

I don't know how to proceed i want to make use of the angular templates and routes for my single page app ( which resides post sign-in ). I am flexible if there is another way. I just need a guide how to use angular seemlessly with rails making use of rails controller to handle my rest request and using routing provided by angular to navigate around in SPA.

Hope i am clear. Feel free to edit this.

like image 448
kishanio Avatar asked Aug 09 '13 16:08

kishanio


2 Answers

here is a great railscasts from ryan bates: http://railscasts.com/episodes/405-angularjs

also here is the source for that railscasts you can get ideas from there:

https://github.com/railscasts/405-angularjs

like image 164
Rodrigo Zurek Avatar answered Sep 20 '22 08:09

Rodrigo Zurek


I'm not familiar with SPA, but I have been working on a tutorial for integrating rails and angularjs, which I'm refining over time. It may provide some answers here - in particular I am using the angular routing to provide a single-page app as you describe: http://technpol.wordpress.com/2013/09/03/angularjs-and-rails-tutorial-index/

like image 33
PaulL Avatar answered Sep 22 '22 08:09

PaulL