Skip to content

Instantly share code, notes, and snippets.

View goz's full-sized avatar
🐌
I may be slow to respond.

goz goz

🐌
I may be slow to respond.
View GitHub Profile
def randomize_photo_file_name
extension = File.extname(photo_file_name)
self.photo.instance_write(:file_name, "#{ActiveSupport::SecureRandom.hex.first(16)}#{extension}")
end
has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" },
:url => "/assets/attachments/:id/:style/:basename.:extension",
:path => ":rails_root/public/assets/attachments/:id/:style/:basename.:extension"
before_post_process :randomize_photo_file_name
class Array
def remove(*args)
string_params = ""
args.each do |arg_item|
string_params += arg_item
end
flatten.collect { |k| k.delete string_params}
end
def repeat(int)
def show
prawnto :prawn => { :page_size => 'A4',
:left_margin => 40,
:right_margin => 30,
:top_margin => 40,
:bottom_margin => 30},
:filename => "invoice_{@transaction.id}_customer_{@transaction.customer_id}.pdf"
render :layout => false
end
<%= link_to "Generate PDF", transaction_url(transaction.id, :format => "pdf") %>
def run cmd, params = "", expected_outcodes = 0
command = %Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")
command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
Paperclip.log(command) if Paperclip.options[:log_command]
output = `#{command}`
unless [expected_outcodes].flatten.include?($?.exitstatus)
raise PaperclipCommandLineError, "Error while running #{cmd}"
end
output
end
def run cmd, params = "", expected_outcodes = 0
command = %Q[#{path_for_command(cmd)} #{params}] # remove this => .gsub(/\s+/, " ")
command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
Paperclip.log(command) if Paperclip.options[:log_command]
output = `#{command}`
unless [expected_outcodes].flatten.include?($?.exitstatus)
raise PaperclipCommandLineError, "Error while running #{cmd}"
end
output
end
rails directory --skip-activerecord
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta3/lib/rails/generators.rb:6:in `require': no such file to load -- active_support/core_ext/kernel/singleton_class (LoadError)
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta3/lib/rails/generators.rb:6:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta3/lib/rails/commands/application.rb:10:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta3/lib/rails/commands/application.rb:10:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta3/lib/rails/cli.rb:30:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta3/lib/rails/cli.rb:30:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/rails-3.0.0.beta3/bin/rails:1:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/rails-3.0.0.beta3/bin/rails:1:in `<top (required)>'
from /usr/local/bin/rails:19:in `load'
sudo env ARCHFLAGS="-arch x86_64" gem install pg
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config