Skip to content

Instantly share code, notes, and snippets.

<% 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| %>
def create_po
provides :js
po = params[:purchase_order]
# do the creating job for the po
render
end
<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;
})
@zhhz
zhhz / form.html
Created January 18, 2009 00:49
merb_form.html.erb
<% @pos.each |purchase_order| do %>
<%= form_for(purchase_order, :action => url(:create_po_purchasing_shopping_lists)) do %>
<%= hidden_field :name => "counter", :value => count %>
<%= partial 'purchasing/purchase_orders/basic_form', :po => po %>
<button class="positive" type="submit">
<img alt="create" src="/images/icons/tick.png"></img>
Create
</button>
<% end =%>
<% end %>
@zhhz
zhhz / ack.vim
Created December 22, 2008 14:12
" all credits to antoine,
" more details see: http://blog.ant0ine.com/2007/03/ack_and_vim_integration.html
function! Ack(args)
let grepprg_bak=&grepprg
set grepprg=ack\ -H\ --nocolor\ --nogroup
execute "silent! grep " . a:args
botright copen
let &grepprg=grepprg_bak
endfunction
z1 = Zoo.all(:condition.....)
z1.to_yaml # this OK
z2 = Zoo.all(:condition...)
z2.to_yaml # this OK
z3 = z1 + z2
z3.to_yaml # bam!. ERROR
zooo = Zoo.all
File.open('zoo.yaml', 'w'){|f| f.puts zooo.to_yaml}
# dm 0.9.8 breaks YAML.dump
zooo = Zoo.all
File.open('zoo.yaml', 'w'){|f| YAML.dump(zooo, f)}
# setting the env to development
RackEnv development
<VirtualHost *:80>
ServerName app.myapp.com
DocumentRoot /Users/zhonghai/apps/ruby/current/public
</VirtualHost>
<VirtualHost *:80>
ServerName app.myapp.com
DocumentRoot /Users/zhonghai/apps/ruby/current/public
# setting the env to development
RackEnv development
</VirtualHost>