Posts

Showing posts from May, 2015

OAuth2 Overview

Image
Introduction OAuth 2 is an authorization framework that enables applications to obtain limited access to user accounts on an HTTP service, such as Facebook, GitHub, and DigitalOcean. It works by delegating user authentication to the service that hosts the user account, and authorizing third-party applications to access the user account. OAuth 2 provides authorization flows for web and desktop applications, and mobile devices. This informational guide is geared towards application developers, and provides an overview of OAuth 2 roles, authorization grant types, use cases, and flows. Let's get started with OAuth Roles! OAuth Roles OAuth defines four roles: Resource Owner Client Resource Server Authorization Server We will detail each role in the following subsections. Resource Owner: User The resource owner is the user who authorizes an application to access their account. The application's access to the user's account is limited to the

Adding new Methods to your association for advanced queries

You're not limited to the functionality that Rails automatically builds into association proxy objects. You can also extend these objects through anonymous modules, adding new finders, creators, or other methods. For example: class Customer < ActiveRecord :: Base has_many :orders do   def find_customer_by_order_id ( order_id ) o = Order . find ( order_id ) o .customer end   end end now in console: >>c=Customer.first  #<Customer id: 1, name: "ttttttttttt", created_at: "2015-04-29 12:30:13", updated_at: "2015-05-05 10:36:06", orders_count: 1>  >>c.orders.find_customer_by_order_id(2)  #<Customer id: 1, name: "ttttttttttt", created_at: "2015-04-29 12:30:13", updated_at: "2015-05-05 10:36:06", orders_count: 1>   If you have an extension that should be shared by many associations, you can use a named extension module. For example: module FindR