Skip to content

Instantly share code, notes, and snippets.

products.collect(&:name).to_sentence
String.Join(", ", OrderLines.select(x => x.Product.name));
require 'PaymentProvider' # Loads "PaymentProvider.dll", a library written in C#
invoice = PaymentProvider::EmailInvoice.new
result = invoice.send_to(@order.email)
module LocalizedJob
module InstanceMethods
def send_later_with_i18n(method, locale, *args)
locale ||= I18n.locale
job = LocalizedJob::LocalizedMethod.new(self, method.to_sym, args)
job.locale = locale
Delayed::Job.enqueue job
end
end
Rails.configuration.to_prepare do
# Makes the the send_later_with_i18n method available to all objects
Object.send(:include, LocalizedJob::InstanceMethods)
end
<%= form_for(@production) do |form| %>
<%= form.label :title, 'Title' %>
<%= form.text_field :title %>
<%= form.fields_for :employee_roles do |role_form| %>
<%= form.label :employee_id %></dt>
<%= form.select :employee_id, ... %>
<%= form.label :role_id %></dt>
<%= form.select :role_id, ... %>
<% end %>
Mime::Type.register "application/vnd.ms-excel", :xls
ActionController::Renderers.add :xls do |object, options|
instance = object.respond_to?(:first) ? object.first : object
options = instance.respond_to?(:xls_options) ? instance.xls_options : {}
self.send_data object.to_xls_data(options), :type => :xls
end
source :gemcutter
gem 'rails', '2.3.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'rails', '2.3.8'
gem 'postgres'
gem 'aws-s3', '0.6.2'
...
gem 'devise'
gem 'warden_oauth'
class User < ActiveRecord::Base
devise :database_authenticatable, :openid_authenticatable, :recoverable, :rememberable, :trackable, :validatable
# Handle creation of user authenticated via OpenID
def self.create_from_identity_url(identity_url)
User.new(:identity_url => identity_url)
end
# Set email as a required field from the Open ID provider