I'm a Ruby on Rails / jQuery web developer. Follow me at @sikachu

Archive for the ‘Ruby’ Category

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 ...

`method_missing` call stack in Ruby

Tuesday, November 23rd, 2010 Posted in Programming, Ruby | 2 Comments »

Just found out something cool from reading "Don’t Know Metaprogramming In Ruby?" from RubyLearning blog. Consider this code snippet: class Person end class Student < Person end class HighSchoolStudent < Student end If you're calling some method that's undefined, let's say we're calling HighSchoolStudent#name Ruby will try ...

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 ...

10 Things you should know about Ruby — #BarcampBKK4

Sunday, October 24th, 2010 Posted in Programming, Ruby | 2 Comments »

I've done a talk about Ruby in Barcamp Bangkok 4 on Oct 24. Here is the slide in case someone want it. 10 things you should know about ruby You can download it if you want. This slide is CC-BY-NC-SA (as some ...

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 ...