วันอาทิตย์ที่ 11 ธันวาคม พ.ศ. 2554

rails 3: How to get the old value of an attribute in Rails

Q: อยากจะได้ค่าก่อนหน้าของแต่ละ attribute ทำอย่างไร เพื่อไว้เปรียบเทียบค่าเก่า ค่าใหม่ ?

A: ให้เพิ่ม _was ต่อท้ายใน attribute นัั้นๆ ได้เลย ก็จะแสดงค่าก่อนหน้ามาให้

วันอังคารที่ 6 กันยายน พ.ศ. 2554

Excel : แทนค่า 0 ด้วยช่องว่าง

Problem : พอดี cell นั้นใช้สูตร copy มาจาก cell อื่น (=A2) แต่ cell ที่ถูกอ้าง (A2) เป็นค่าว่าง ผลลัพธ์ที่ cell ที่อ้างจึงมีค่าเป็น 0 แต่อยากจะให้แสดงเป็นค่าว่างเหมือนกัน

Solution : คลิกขวา cell ที่่อ้าง เลือก format cells ที่ Tab แรก Number ช่อง Category เลือก Custom ในช่อง Type พิมพ์ 0;-0;;@

วันอาทิตย์ที่ 28 สิงหาคม พ.ศ. 2554

rails 3: Rails Footnotes

1. gem 'rails-footnotes', '>= 3.7', :group => :development
2. create footnotes.rb in initializers
3. insert code :
if defined?(Footnotes) && Rails.env.development?
Footnotes.run! # first of all

# ... other init code
Footnotes::Filter.prefix = 'mvim://open?url=file://%s&line=%d&column=%d'
end