Hoptoad ❤ Heroku
Wednesday, December 15th, 2010 Posted in My Project, Ruby, Ruby on Rails | No Comments »Recently, I've started to migrate my application to Heroku. While most of the functionalities are there, one of the thing I was missing is Hoptoad's deploy tracking, as you cannot add a deploy hook to call Rake task as you ...
My Devise custom routes
Monday, December 13th, 2010 Posted in My Idea, Programming, Ruby, Ruby on Rails | 6 Comments »Since the release of Rails 3, I've been using Devise as my authentication gem. While it delivers everything I need, its default route doesn't look really good when I have only one authentication scope, such as User. The default route ...
Gems — Follow up from my talk at #BarcampBKK4
Friday, October 29th, 2010 Posted in Programming, Ruby, Ruby on Rails | No Comments »I think I should noted down two gems that I mentioned in my talk. Omniauth — a middleware that help you authenticate user to various SSO sites, such as Facebook Connect, Twitter, Google Account Devise — fully-functional authentication system. If you write ...
RailsCamp (Thailand) 2010
Wednesday, October 20th, 2010 Posted in News, Programming, Ruby, Ruby on Rails | 1 Comment »เพิ่งทราบข่าวมาวันนี้ว่าที่ประเทศไทย จะมีคนจัดงาน RailsCamp แล้ว! RailsCamp (Thailand) 2010 ดีใจ + ตกใจนิดหน่อย เพราะเป็นโปรเจคที่คิดไว้ตั้งแต่เมื่อ 2-3 ปีที่แล้ว ตั้งแต่เมื่อตอนที่เขียน Rails ใหม่ๆ ว่าอยากให้มีงานที่เป็น Ruby on Rails Community ของคนไทย ... ในเมื่อมีคนทำแล้ว ผมก็ขอสนับสนุนเต็มทีครับ ผมคงจะเตรียมเรื่องไปพูดนิดหน่อย ไม่แน่ใจเหมือนกันว่าเรื่องอะไร แต่ถ้าดูจาก Schedule ปัจจุบัน อาจจะได้พูดเรื่อง Behavior Driven Development using Cucumber หรือไม่ก็ Devise เพราะว่าเรื่องใหญ่ๆ อย่าง Rails 3 ...
Possible pitfall on ActiveRecord::Base#create
Saturday, August 21st, 2010 Posted in Ruby, Ruby on Rails | 3 Comments »I came across this a while ago when I was trying to clean up my code. Just write it down so you won't follow me :) Consider that Post having :title attribute and class Post < ActiveRecord::Base validates_presence_of :title end Well, what do ...
Ruby 1.9.2 is out!!
Wednesday, August 18th, 2010 Posted in News, Programming, Ruby, Ruby on Rails | 1 Comment »Just got the news in Twitter today that Ruby 1.9.2 is out! This is the Ruby that we've been long-awaits which shouldn't have any strange compatibility issue with the upcoming Rails 3, and wayyyy faster than 1.8.7. The timing couldn't be ...
เจออะไรใน Rails 3: เพิ่มพลัง ActiveRecord#find (ตอนที่ 2)
Friday, February 12th, 2010 Posted in Ruby, Ruby on Rails | 1 Comment »เจออะไรใน Rails 3 เป็นสกู๊ปพิเศษสำหรับนำเสนอสิ่งใหม่ๆ ที่จะมีเพิ่มขึ้นมาใน Ruby on Rails 3.0 หลังจากที่ผมนำเสนอเรื่องของการ deprecate options ทั้งหมดของ ActiveRecord#find แล้วเปลี่ยนเป็นเมธอดที่ทำหน้าที่คล้ายๆ กับ named_scope กันไปแล้ว ตอนนี้ผมไปเจอข้อมูลจาก @lifo ซึ่งพูดเพิ่มเติมในเรื่องของเมธอดที่จะถูก deprecated และเมธอดที่ให้ใช้แทนครับ สิ่งที่จะถูกถอดออกไป การเรียกใช้ #find โดยมี option hash นั้นจะ deprecated ออกไป User.find(:first, :where => {:status => "suspended"}) แต่อย่างไรก็ตาม #find method จะยังคงอยู่ โดยคุณสามารถใช้มันเพื่อหา record ตาม ...
เจออะไรใน Rails 3: เข้ารหัส cookie และสร้าง cookie ที่ไม่มีวันหมดอายุอย่างง่ายๆ
Thursday, February 11th, 2010 Posted in Ruby, Ruby on Rails | No Comments »เจออะไรใน Rails 3 เป็นสกู๊ปพิเศษสำหรับนำเสนอสิ่งใหม่ๆ ที่จะมีเพิ่มขึ้นมาใน Ruby on Rails 3.0 เมื่อก่อนนี้ ถ้าหากเราต้องการที่จะทำ cookie ที่ไม่มีวันหมดอายุ (เช่น remember me) เราจำเป็นที่จะต้องกำหนดเวลาหมดอายุของ cookie เอง เช่น cookies[:authorization_key] = { :value => @user.authorization_key, :expires => 20.years.from_now.utc } แต่หลังจาก commit ของ DHH อันนี้ ทำให้เราสามารถเขียนใหม่ได้เป็น cookies.permanent[:authorization_key] = @user.authorization_key นอกจากนั้น เพื่อเพิ่มความปลอดภัยให้กับ Cookie เราก็ยังสามารถที่จะจับมัน signed ...
เจออะไรใน Rails 3: ใส่ flash message ลงไปใน redirect_to ได้เลย
Wednesday, January 20th, 2010 Posted in Ruby, Ruby on Rails | No Comments »เจออะไรใน Rails 3 เป็นสกู๊ปพิเศษสำหรับนำเสนอสิ่งใหม่ๆ ที่จะมีเพิ่มขึ้นมาใน Ruby on Rails 3.0 ความเป็นมา ปกติแล้วใน Rails 2 ถ้าเราต้องการที่จะตั้งค่า flash message ก่อนที่จะทำการ redirect เราจำเป็นทีจะต้องตั้งค่ามันก่อนที่จะเรียก redirect_to เช่น class UsersController < ApplicationController def create @user = User.new(params[:user]) if @user.save ...
เจออะไรใน Rails 3: เพิ่มพลัง ActiveRecord#find
Saturday, January 2nd, 2010 Posted in News, Ruby, Ruby on Rails | No Comments »เจออะไรใน Rails 3 เป็นสกู๊ปพิเศษสำหรับนำเสนอสิ่งใหม่ๆ ที่จะมีเพิ่มขึ้นมาใน Ruby on Rails 3.0 ความเป็นมา หลายคนนั้นคงจะรู้จักกับฟีเจอร์ named_scope ที่ได้เปิดตัวออกมาพร้อมกับ Rails 2.1 ทำให้เราสามารถที่จะเขียน scope แล้วนำ scope นี้ไปใช้ได้ใหม่เรื่อยๆ เป็นไปตามหลักของ DRY เช่น class Post < ActiveRecord::Base named_scope :published, :conditions => { :status => :published } named_scope :latest, lambda { |limit| ...


