This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Building authenticated and expiring URL for S3 | |
# Based on | |
# http://github.com/logandk/paperclip_hacks/blob/master/lib/paperclip.rb | |
# and | |
# http://thewebfellas.com/blog/2009/8/29/protecting-your-paperclip-downloads | |
module Paperclip | |
class Attachment | |
def authenticated_url(style = nil, expires_in = 5.minutes) | |
if @storage.to_s == 's3' && file? | |
AWS::S3::S3Object.url_for(path(style || default_style), bucket_name, :expires_in => expires_in, :use_ssl => s3_protocol == 'https') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails-FormBuilder for creating forms with <label>-Tags | |
class LabeledFormBuilder < ActionView::Helpers::FormBuilder | |
helpers = field_helpers + | |
%w{date_select datetime_select time_select} + | |
%w{collection_select select country_select time_zone_select} - | |
%w{radio_button hidden_field label fields_for} # Don't decorate these | |
helpers.each do |name| | |
define_method(name) do |field, *args| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ya2yaml' # Better than to_yaml, because it saves as UTF-8 and sorts hash by keys | |
namespace :locales do | |
desc "Parses ActiveRecord models and updates locale files" | |
task :update => :environment do | |
Dir.glob(File.join(RAILS_ROOT, 'config', 'locales', '*.yml') ).each do |locale_file| | |
# Read single locale file | |
locale_hash = YAML.load(File.read(locale_file)) | |
language = locale_hash.keys.first | |
NewerOlder