ok makasih bgt. On Oct 19, 2009, at 10:34 AM, Arie Kusuma Atmaja wrote:
> 2009/10/19 Bobby Adi Prabowo <[email protected]>: > > > akhirnya saya ubah jadi seperti ini > > > > def index > > > > hash = params[:search] > > > > if !hash.nil? > > if !hash["date_birth_equals(1i)"].blank? && !hash > > ["date_birth_equals(2i)"].blank? && !hash["date_birth_equals > > (3i)"].blank? > > hash["date_birth_equals"] = hash["date_birth_equals(1i)"] + > > "-" + hash["date_birth_equals(2i)"] + "-" + hash["date_birth_equals > > (3i)"] > > > > end > > > > if !hash["register_date_equals(1i)"].blank? && !hash > > ["register_date_equals(2i)"].blank? && !hash["register_date_equals > > (3i)"].blank? > > hash["register_date_equals"] = hash["register_date_equals > > (1i)"] + "-" + hash["register_date_equals(2i)"] + "-" + hash > > ["register_date_equals(3i)"] > > > > end > > hash.delete("date_birth_equals(1i)") > > hash.delete("date_birth_equals(2i)") > > hash.delete("date_birth_equals(3i)") > > hash.delete("register_date_equals(1i)") > > hash.delete("register_date_equals(2i)") > > hash.delete("register_date_equals(3i)") > > end > > > > @search = Student.search hash > > @students = @search.paginate :page => params[:page], :per_page > => > > 10, :order => 'id DESC' > > Pindahkan semua proses ini ke Model student.rb dan Anda seharusnya > bisa mulai me-refactor codes Anda di model Anda setelah itu. Jadi > kalau sudah bersih seharusnya codes Anda di controller tinggal : > > @students = Student.bobkeren_search(your_hash_parameters) > > > ada yang punya ide lebih baik? > > May The Force be with you. http://bit.ly/Oue4s > [Non-text portions of this message have been removed]

