reference: blog.thirst.co
In a nutshell, STI allows you to create subclasses of a particular database table. Using a single table, you can cast rows to specific objects that extend the base model.
Lets say we have a model Computer
reference: blog.thirst.co
In a nutshell, STI allows you to create subclasses of a particular database table. Using a single table, you can cast rows to specific objects that extend the base model.
Lets say we have a model Computer
class ImageUploader < CarrierWave::Uploader::Base | |
class FilelessIO < StringIO | |
attr_accessor :original_filename | |
attr_accessor :content_type | |
end | |
before :cache, :convert_base64 | |
def convert_base64(file) |
class API::V1::BaseController < ApplicationController | |
skip_before_filter :verify_authenticity_token | |
before_filter :cors_preflight_check | |
after_filter :cors_set_access_control_headers | |
def cors_set_access_control_headers | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS' |
The guide will assume that we are dealing with a pre-existing application that has two models: Album and Artist. An album belongs to an artist and an artist has many albums.
This guide is for Rails 4.0.0+ only.
These gems can always be replaced with alternatives, but they will be good for demonstration. Add the following gems to your Gemfile:
def random_location_from(center_lat, center_lng, distance) | |
radius = distance | |
radiusInDegrees=radius/111000.to_f | |
r = radiusInDegrees | |
origin_x = center_lat | |
origin_y = center_lng | |
u = rand(0.00..1.00) | |
v = rand(0.00..1.00) |
var path = require('path'); | |
var webpack = require('webpack'); | |
// var fs = require('fs'); | |
var GlobalizePlugin = require('globalize-webpack-plugin'); | |
module.exports = { | |
name: 'vets4pets', | |
target: 'web', | |
version: '0.0.1', | |
author: 'Chipotle Software (c) 2016', |
# Hey Everyone - | |
# I've been doing some googling here and wanted to ask if anyone's done this before - streamed flash video (*.flv) via Ruby? | |
# Basically, I'm doing some R&D on a possible future project to use RoR for the site/db access, and Flash to stream video. Thing is, the user needs to be authorized for the video, and it needs to be streamed so it isn't cached on the client-end (for copyright protection purposes - yeah I hate it too, but gotta do it). | |
# I've seen one tutorial using Ming to do that, but I'd prefer something that has a separate server-side application, and separate client-side application built in Flash, so I have more control over the look and feel of the application, as well as can embed other interesting things in there if I want. | |
# I've taken a look at Red5 (http://osflash.org/red5), but seeing as it's in Java, I'm not too keen on working with it. | |
# Part of the reason I want to do this in Ruby is obviously so I can work with it through Rails, -and- so I can use Ruby to fetch videos f |
origin: jerodsanto Blog
Since Rails 3 you’ve been able to configure an app to handle exceptions, which you want to point right at your router. To do this, add the following to config/application.rb: