Skip to content

Instantly share code, notes, and snippets.

@zhhz
zhhz / shell
Created February 21, 2009 19:29
1. Set the mysql bin path if you installed it by yourself in /usr/local/mysql
#you have to set your mysql bin on your path:
PATH=$PATH:/usr/local/mysql/bin
2. Remove the default mysql executable files
$ sudo mv /usr/bin/mysql_config usr/bin/mysql_config.old
$ sudo mv /usr/bin/mysql usr/bin/mysql
install do-mysql
Installing do_mysql-0.9.11
Building native extensions. This could take a while...
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb merb:gem:install
checking for mysql.h... no
checking for main() in -lmysqlclient... no
checking for mysql_query()... no
checking for mysql_ssl_set()... no
# from dm-constraints/lib/dm-constraints/delete_constraint.rb
when :destroy!
if children
# not sure why but this lazy_load is necessary
# otherwise children will not be deleted with destroy!
children.lazy_load
children.destroy!
end
....
# from dm-constraints/lib/dm-constraints/delete_constraint.rb
when :destroy!
if children
# not sure why but this lazy_load is necessary
# otherwise children will not be deleted with destroy!
children.lazy_load
children.destroy!
end
....
#I am not sure if this is the feature(it is designed to do so),
# or I'm doing it wrong. Here is the situation I have:
# as of DM version: 0.9.9
class Order
before :destroy, :destroy_items
....
has n, items ...
def destroy_items
# price_letter.pdf.erb
<%=
require "prawn/measurement_extensions"
require "prawn/table"
pdf = Prawn::Document.new(
:page_size => "A4",
:left_margin => 2.cm,
:right_margin => 2.cm,
:top_margin => 2.cm,
pdf = Prawn::Document.new(
:page_size => "A4",
:left_margin => 2.cm,
:right_margin => 2.cm,
:top_margin => 2.cm,
:bottom_margin => 1.5.cm
)
# logo
logo = image_dir + 'logo.jpg'
pdf.image logo, :position => :center
def priceletter
provides :pdf
...
end
<%= form_for(@price_letter, :action => resource(:ordering, @price_letter, :priceletter, :format => "pdf"), :class => "form") do %>
# fields for ....
<% end =%>
Merb::BootLoader.after_app_loads do
Merb.add_mime_type(:pdf, :to_pdf, %w[application/pdf], "Content-Encoding" => "gzip")
end