Tutorial by Examples: concern

To avoid repetition in nested routes, concerns provide a great way of sharing common resources that are reusable. To create a concern use the method concern within the routes.rb file. The method expects a symbol and block: concern :commentable do resources :comments end While not creating a...
module OmniConcern extend ActiveSupport::Concern def create auth_params = request.env["omniauth.auth"] provider = AuthenticationProvider.get_provider_name(auth_params.try(:provider)).first authentication = provider.user_authentications.where(uid: auth_params.uid).first...
module OmniauthAttributesConcern extend ActiveSupport::Concern module ClassMethods Add Methods here end end In this concern we can create methods for each social media to fetch and store attributes. def twitter params (params['info']['email'] = "dummy#{SecureRan...
Worse ViewController: // ... myMethod: function () { this.getView().lookup('myhappyfield').setValue(100); } //... View: //... items: [ { xtype: 'textfield', reference: 'myhappyfield' } ] //... Better ViewController: // ... myMethod: function () { ...
Regular expression matching is a powerful tool (in Java, and in other contexts) but it does have some drawbacks. One of these that regular expressions tends to be rather expensive. Pattern and Matcher instances should be reused Consider the following example: /** * Test if all strings in a lis...
function sum(numbers) { var total = 0; for (var i = numbers.length - 1; i >= 0; i--) { total += numbers[i]; } return total; } It's a procedural code with mutations (over total).

Page 1 of 1