This file contains 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
class AddConstraintsToAssets < ActiveRecord::Migration | |
def self.up | |
execute "alter table #{Asset.table_name} | |
add constraint assets_check_kind | |
check (kind in (#{ Asset::KINDS.collect{|a| "'#{a}'"}.join(',') }));".to_line | |
end | |
def self.down | |
execute "alter table #{Asset.table_name} | |
drop constraint assets_check_kind;".to_line |
This file contains 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
# The test | |
setup do | |
@asset = Asset.new({:kind => 'image', | |
:user_rights => 3, | |
:everyone_rights => 1, | |
:description => "nice dragon", | |
:object => File.new(File.expand_path(File.dirname(__FILE__) + '/asset_test/dragon.svg')) | |
}) | |
end | |
This file contains 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 'rubygems' | |
require 'sinatra' | |
require 'tempfile' | |
class Jaxer | |
class << self | |
def json_to_png(json) | |
# producing tempfile | |
file = Tempfile.new('jaxer') |
This file contains 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
# command used to start thin | |
thin -s 1 -C thin/production_config.yml -R thin/config.ru start | |
# thin/config.ru | |
require 'lib/sinatra/lib/sinatra' | |
This file contains 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
module HasAsset | |
def included base | |
base.class_eval do | |
before_create :add_asset | |
before_update :edit_asset | |
end | |
end | |
private | |
def edit_asset |
This file contains 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
Errno::EPIPE in Item typesController#update | |
Broken pipe | |
RAILS_ROOT: /Users/max/Sites/printio/products | |
Application Trace | Framework Trace | Full Trace | |
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:175:in `write' | |
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:175:in `write0' | |
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:151:in `write' |
This file contains 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
asset.put(:service_update, { | |
:object => Base64::encode64s(source_data), | |
:filename => "#{Digest::MD5.hexdigest(source_data)}.png", | |
:description => self.method(options[:description]).call }) |
This file contains 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
module Beer | |
def drink | |
"gulp" | |
end | |
end | |
class Mug | |
include Beer | |
end | |
This file contains 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
module Paperclipful | |
module UploadedFileExtensions | |
def to_xml(options = {}) | |
options.reverse_merge! :indent => 2, :root => self.class.to_s.split('::').last.underscore | |
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent], :root => options[:root]) | |
xml.instruct! unless options[:skip_instruct] | |
self.rewind | |
xml.tag!(options[:root], :type => :attachment) do | |
xml.original_path self.original_path |
This file contains 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
{"commit"=>"Create", "action"=>"create", "authenticity_token"=>"xIhGb/nKQfrrKzaJ/J2iQOrupN+81AfreutXOdIoNqY=", "controller"=>"prototypes", "prototype"=>{"title"=>"", "surface_views_attributes"=>{"new_1"=>{"description"=>"asdf", "picture"=>#<File:/tmp/RackMultipart.83249.5>}, "new_2"=>{"picture"=>#<File:/tmp/RackMultipart.83249.6>}, "new_3"=>{"picture"=>nil}}, "item_view_attributes"=>{"picture"=>nil}}} |