The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
The CARB stack: Coffee + Angular + Rails + Bower

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
The CARB stack: Coffee + Angular + Rails + Bower Posted: Dec 5, 2013 6:43 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jan Lelis.
Original Post: The CARB stack: Coffee + Angular + Rails + Bower
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;). So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

Advertisement

AngularJS is a great way to build modern web apps and this affects Rails programmers. The combination of both is an excellent choice: Build your single-page app in Angular and let it communicate via JSON with your Rails-API backend (btw, this is exactly what we did for palava). However, you might ask yourself, what the best way to combine Angular and Rails is. Should you use the JavaScript tools world (grunt, yoeman, etc.) or should you prefer the Ruby tools (thor, sprockets)?

Of course, this decision depends on you and your background. For me, the answer is clear: I want to stay in Ruby land. I am familiar with it and it works very well. Why should I throw the tools away for the same functionality, just because they are built in JavaScript? Don’t get me wrong, you should try out yoeman for a new angular project, it is fantastic. But nevertheless.. I like the Ruby stack. The CARB stack.

What’s out there?

Before I’ll promote my own gem, a quick overview of projects with similar scope:

angularjs-rails is an easy way to make Angular available from sprockets. However, I will use a more generic method to achieve this, so we won’t need it.

Ebenezer is an approach to normally use Rails, but use the JavaScript stack at the same time. Check out the blog posts, if this sounds interesting to you.

AngularJS Rails Resource sits on the angular side. It makes communicating with your Rails backend super simple. Awesome!

The bottom two projects are generators for working with Angular. I find generators extremely useful. Their purpose is not to automatically create tons of code, it is more about creating the right files in the right places with minimal boilerplate content to guide you. Especially the ng-rails gem is designed very well!

To conclude, what should an auxiliary gem do for you? In my opinion, it should:

  • manage including AngularJS in Rails
  • contain generators
  • give me tools on the Angular side to work with Rails

It should enforce conventions, but leave the programming to the programmer.

Bower is simple

I am not fan of using bundler/gems to include a frontend JavaScript library, since it adds more complexity to dependency management. There are better solutions for managing frontend libraries and one of them is Bower by twitter. It is easy to use and super lightweight (some people even say, it is not much more than a fancy link shortener). While it does not have too much features, using it allows you to always have the overview of which versions of libraries you are running. I am often confused about this information when using a JavaScript library that comes out of a gem. And, of course, it is better than using plain JavaScript files without dependency management at all!

This is the B of CARB.

Coffee is good

You should use CoffeeScript. It is popular amongst Ruby programmers. For a reason.

This is the C of CARB.

Introducing Regular (Rails + Angular)

Regular is my attempt to implement the CARB stack. It depends on Bower to provide Angular. It comes with generators that promote a convention to organize your Angular project files. It generates Coffee. And it advices you to use AngularJS Rails Resource, because other developers have already thought about how to work with Rails from Angular.

CC-BY (DE)

Read: The CARB stack: Coffee + Angular + Rails + Bower

Topic: Review: Logitech FabricSkin Keyboard Folio Previous Topic   Next Topic Topic: The Virtual Clock Test Pattern

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use