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
this is my test with cocode.io |
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 separate_gift(task) | |
gift = {} | |
[:gift_quantity, :unit_price, :gift_type, :supplier].each do |prop| | |
gift["#{prop}"] = task["#{prop}"] | |
task.delete("#{prop}") | |
end | |
# task.delete("active_gift") | |
gift["task_id"] = task["id"] | |
[task, gift] | |
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 create | |
puts "NEW" | |
offer = Offer.find(params[:offer_id]) | |
if params[:offer_id] | |
task = JSON.parse(params[:tasks]) | |
unless task.nil? | |
task["active_gift"]=="on" ? active_gift = true : active_gift = false | |
task["active_gift"] = active_gift | |
active_gift = true if task["active_gift"] | |
task, gift = separate_gift(task) |
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
['gift', 'encoding'].each do |param| | |
eval <<EOC | |
task["active_#{param}"]=="on" ? active_#{param} = true : active_#{param} = false | |
task["active_#{param}"] = active_#{param} | |
active_#{param} = true if task["active_#{param}"] | |
task, #{param} = separate_#{param}(task) | |
EOC | |
end | |
puts "#{active_gift} active_gift" | |
puts "#{active_encoding} active_encoding" |
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
emacs -q --eval '(condition-case err (progn (load "~/.emacs") (kill-emacs 0)) (error (kill-emacs 1)))' | |
# Source http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/bed5b2bd8b237f5a?pli=1 |