Using rails-api to build an authenticated JSON API with warden | code - lucatironi. An updated version of my previous tutorials on building an authenticated JSON API with Ruby on Rails In this tutorial I will build a small web application that provides a JSON API to manage customers through a REST interface. The requests to the endpoints will be authenticated through a token based authentication strategy, passing custom headers (X-User-Email and X-Auth-Token) containing the user’s credentials. A sessions endpoint is available to issue a new authentication token on login and disposing it on logout. The goal of the tutorial is building the base of an up-to-date, well tested, minimal and functional backend API that can be used for clients such as Angular/Ember web apps or even Mobile applications. Take a look to the previous tutorials to have an idea of the differences with those examples.
Requirements Rails::API is a subset of a normal Rails application, created for applications that don’t require all functionality that a complete Rails application provides. Setup Testing. Environment Specific Configuration In AngularJS using Grunt - Newtriks LTD. Written by Simon Bailey One aspect of Rails I love is the simplicity of environment specific configuration. Out the box, Rails provides configuration for development and production environments and additions are effortless to implement. Using Angular, I typically create a constants module for the application configuration e.g. api url’s, third party service specific data, etc. All of these can change based on the applications environment with which it is deployed to. This post details an approach I used to configure an AngularJS app constants based on configuration specific to the environment using Grunt tasks. AngularJS & Grunt I will use Yeoman as usual to setup the project.
Plan of action Create an AngularJS app.Create a development config file.Create an Angular constants module.Setup grunt tasks to inject the environment specific data into the Angular app constants.Load the module constants into the app.Configure grunt tasks for app builds based on multiple environments. Create the app. 15 Useful AngularJS Tools For Developers - Hongkiat. Thinking of dipping your toes into Angular? If you have gone through our 10 best tutorials to learn AngularJS post and would like to play around with Angular on your own, you’re on the right post. We have here some tools that can streamline your development workflow. We’re looking at 15 of the best IDEs, text editors, tools for testing & debugging, modules and development tools and apps for building with Angular.
If you have your favorite tools or apps, do share them with us in the comments below. Recommended Reading: More Posts On AngularJS IDE & Text Editor In the programming world, there are two types of editors: full featured Integrated Development Environment (IDE) and lightweight text editors. WebStorm WebStorm is suited not just for Javascript but also HTML and CSS. Aptana Aptana is a free open source IDE which is actually the customized version of Eclipse focusing on Javascript, HTML, CSS and other web goodies. Sublime Text More on Sublime Text: Testing & Debugging Tools Karma Jasmine. Using JSON Web Tokens to Authenticate JavaScript Front-Ends on Rails.
While working on a project recently, I encountered a problem I haven't had to tangle with in a while: authenticating front-end applications against a Rails API. The last time I was even dabbling in this realm, jQuery was everything, CORS was still in its infancy, and JSONP was still a thing (that's not a thing anymore, right?). The only way I ever managed to scrape by in this hostile environment was to let Rails' asset pipeline serve up the front-end app and rely on same-origin requests and regular ol' cookies to handle authentication.
I didn't like it, but I survived. Eventually, I got away from front-end concerns almost completely. Since those dark times, a few tools have cropped up and improved the landscape. At first, I got started by symlinking the front-end to public/ in my Rails app and setting protect_from_forgery with: :null_session.
There were a few other, related problems to solve, but I want to focus on how I did authentication for the rest of this post. Defining the valid? Rails 4, Cors, JWT, and Devise. Simple AngularJS Authentication with JWT | Thinkster. How To Handle User Authentication With AngularJSDevdactic. Techniques for authentication in AngularJS applications — Opinionated AngularJS. How to do loading spinners, the Angular way. Updated on 6/25/15 One interesting problem I had to solve recently was how to elegantly deal with loading spinners on the page without violating separation of concerns.
Many times, the spinner element is in an area of the DOM controlled by the relevant controller and you can simply toggle a variable in scope and it just works. For example: app.controller('myCtrl', function ($scope, $http) { $scope.loading = true; $http.get('/some/awesome/content') .success(function (data) { }) .catch(function (err) { }) .finally(function () { $scope.loading = false; });}); This works great, but what if your spinner is in a DOM tree that isn't managed by the controller that needs to show it?
Even if you manage to solve this scenario, how then do you solve situations where you need to show/hide multiple loading spinners? The directive: Of course, we love directives and some kind of spinner directive seems to make immediate sense. See how the directive calls spinnerService. Transclusion The service: 10 Top Mistakes AngularJS Developers Make.