background preloader

Ruby

Facebook Twitter

Capistrano/README.md at master · capistrano/capistrano. Angularjs - Angular send POST request with resource service to Rails API. Angularjs - Sending an Angular post request with parameter to Rails API. Cyu/rack-cors. Angular + Rails = Match in Heaven - Stephen Bussey. About 4 months ago, I began my journey into Angular + Rails integrated.

Angular + Rails = Match in Heaven - Stephen Bussey

My company, SalesLoft, decided to try this out on a project and we are all really loving the outcome right now. There were some bumps along the way, and my goal today is to help you get past those initial pains, explaining as much as I can in this format, and leaving with a template that you can apply to other projects. Let’s dive in! This is going to be a very newbie friendly tutorial, skip to the good parts if you are above that. Please go to the github project because I can’t cover the entire app in a blog post! Ruby / Rails (gem) on systemBower install ( Rails knowledge.

Let’s create our Rails app (without testunit for now) rails new -T tutorial Once we do that, let’s add in our bower components. Bower.json The bowerrc file will tell bower where to install the components at, and we will put it in a more Rails-friendly place than the default .bowerrc Now you can run bower install and watch your components download. How to convert activerecord results into a array of hashes. Toptierlabs/api_explorer. Rails Routing from the Outside In. 1 The Purpose of the Rails Router The Rails router recognizes URLs and dispatches them to a controller's action.

Rails Routing from the Outside In

It can also generate paths and URLs, avoiding the need to hardcode strings in your views. 1.1 Connecting URLs to Code When your Rails application receives an incoming request for: it asks the router to match it to a controller action. 1.2 Generating Paths and URLs from Code You can also generate paths and URLs. And your application contains this code in the controller: and this in the corresponding view: then the router will generate the path /patients/17. 2 Resource Routing: the Rails Default Resource routing allows you to quickly declare all of the common routes for a given resourceful controller. 2.1 Resources on the Web Browsers request pages from Rails by making a request for a URL using a specific HTTP method, such as GET, POST, PATCH, PUT and DELETE.

It asks the router to map it to a controller action. 2.2 CRUD, Verbs, and Actions 2.3 Path and URL Helpers. Active Record Query Interface. If you're used to using raw SQL to find database records, then you will generally find that there are better ways to carry out the same operations in Rails.

Active Record Query Interface

Active Record insulates you from the need to use SQL in most cases. Code examples throughout this guide will refer to one or more of the following models: All of the following models use id as the primary key, unless specified otherwise. Active Record will perform queries on the database for you and is compatible with most database systems (MySQL, PostgreSQL and SQLite to name a few). Regardless of which database system you're using, the Active Record method format will always be the same. 1 Retrieving Objects from the Database To retrieve objects from the database, Active Record provides several finder methods. The methods are: bindcreate_withdistincteager_loadextendingfromgrouphavingincludesjoinslimitlocknoneoffsetorderpreloadreadonlyreferencesreorderreverse_orderselectuniqwhere.

Rails-api/rails-api. Building a RESTful API in a Rails application. Building and documenting API in Rails. These are really exciting times for web developers.

Building and documenting API in Rails

New JavaScript frameworks emerge constantly, completely changing the way we think about building web applications. With libraries such as AngularJS, Ember.js or Backbone.js, the server is no longer responsible for generating complete pages. Its role is often reduced to serving as a backend for client-side application. This approach has many advantages. To name a few: it allows better separation between presentation and business logic better performance for the user - instead of reloading the whole page, only parts that need to change are replaced reduced resources usage - fetching only small chunks of data instead of rendering whole pages, as well as pulling large parts of business logic into web browser, can be a huge relief for your web server and as a result - for your pocket it can save you substantial amount of work if you’re creating multiple clients, for example website and native mobile clients for iOS, Android etc.