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
<script type="text/javascript" > | |
jQuery.ajaxSetup({ | |
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} | |
}); | |
jQuery.fn.submitWithAjax = function() { | |
this.submit(function() { | |
$.post(this.action + '.js', $(this).serialize(), null, "script"); | |
return false; | |
}) |
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
def create_po | |
provides :js | |
po = params[:purchase_order] | |
# do the creating job for the po | |
render | |
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
<% if @purchase_order %> | |
$("div.remote_<%= @counter %>").text("done"); | |
<% else %> | |
<% if @params['vendor_name'] == "Enter the vendor's name" || @params['purchase_order'].nil? %> | |
$("#vendor_name").focus(); | |
$("#error_<%=@counter%>").after('<span class="error">Vendor is required.</span>'); | |
<% end %> | |
<% @params['cb3_ids'].each do |cb3_id| %> | |
<% %w{quantity unitsize price bt tcost}.each do |word| %> |
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
Merb::BootLoader.after_app_loads do | |
Merb.add_mime_type(:pdf, :to_pdf, %w[application/pdf], "Content-Encoding" => "gzip") | |
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
<%= form_for(@price_letter, :action => resource(:ordering, @price_letter, :priceletter, :format => "pdf"), :class => "form") do %> | |
# fields for .... | |
<% 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
def priceletter | |
provides :pdf | |
... | |
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
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 |
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
# 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, |
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
#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 |
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
# 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 | |
.... |