![]() ![]() |
Ror Search N View, view and database |
Mar 28 2008, 01:12 PM
Kiriman
#1
|
|
|
Ahli Baru Grup: Learning Kiriman: 8 Penyertaan: 27-March 08 Dari: somewhere on earth Ahli ke- 45,088 |
salam n hai to all..
sy pun br gune ruby on rails nih..byk lg xtau..nway nk tnye pada sesape yang tau cara nk search multiple table and view parent and child record gn ror ni..mmg ade wat search by text but dia hnya baca kt satu table jer..anyone can help me...thank you.. |
|
|
|
Mar 28 2008, 03:40 PM
Kiriman
#2
|
|
|
Ahli Rajin ![]() ![]() ![]() ![]() Grup: Members Kiriman: 550 Penyertaan: 12-March 05 Ahli ke- 6,834 |
guna search query biasa je bro..wat join table..sql query jek.
Kiriman ini telah diubahsuai oleh spirit: Mar 28 2008, 03:40 PM -------------------- Once a new technology starts rolling, if you're not part of the steamroller, you're part of the road.
- Stewart Brand - |
|
|
|
Mar 29 2008, 10:28 AM
Kiriman
#3
|
|
|
Ahli Baru Grup: Learning Kiriman: 8 Penyertaan: 27-March 08 Dari: somewhere on earth Ahli ke- 45,088 |
ok..tqvm..spirit..
but i still had a problem to view the result..its error occur at <%= pagination_links(@room_pages) %> and <% for room in @rooms %>..any idea..thank you |
|
|
|
Mar 29 2008, 06:26 PM
Kiriman
#4
|
|
|
Ahli Rajin ![]() ![]() ![]() ![]() Grup: Members Kiriman: 550 Penyertaan: 12-March 05 Ahli ke- 6,834 |
kat sini ramai nak bantu tapi tak dapat nk tolong.mereka tak paham apa yang ko cuba sampaikan.dont expect us know how u wrote the code and error occur.aku rasa main error ko adalah kat <% for room in @rooms %>.pagination tu hanya untuk view page yang ko limitkan.so leh tak ko disable dulu kod pagination tu dan tumpu pada kod yang ko nak outputkan dalam looping tu.cek balik model dan controller ko.its better ko setel satu-satu dulu
-------------------- Once a new technology starts rolling, if you're not part of the steamroller, you're part of the road.
- Stewart Brand - |
|
|
|
Mar 29 2008, 07:54 PM
Kiriman
#5
|
|
|
Ahli Baru Grup: Learning Kiriman: 8 Penyertaan: 27-March 08 Dari: somewhere on earth Ahli ke- 45,088 |
owh..sorry..ni error yg ckp tuh...paginate tu aku dah buang
--------------------------------------------------------------- You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each Extracted source (around line #5): 2: 3: 4: 5: <% @rooms.each do | room | %> 6: <%unless room.nil? %> 7: 8: <table > ------------------------------------------------------------ (/model/hotel.rb) class Hotel < ActiveRecord::Base has_many :rooms ----------------------------------------------------------- (/model/room.rb) class Room < ActiveRecord::Base belongs_to :hotel ------------------------------------------------------------- (/controller/store_controller) ---> ni aku x sure sbb aku pun br dapt dr forum lain td..kalo korang ade idea? def viewall sara = "select hotels.hotelName, hotels.hrating_type, rooms.roomName,rooms.roomPrice from hotels, rooms where hotels.hotelNo='SRH' and rooms.hotelNo='SRH' " @rooms+Room.find_by_sql(sara, param[:id]) end ------------------------------------------------------------------------ output yang aku nk sbnry name hotel n rooms yg hotel tu ade..so aku join kan table hotels ngan room sgn sql... thank you |
|
|
|
Mar 29 2008, 08:37 PM
Kiriman
#6
|
|
|
Ahli Rajin ![]() ![]() ![]() ![]() Grup: Members Kiriman: 550 Penyertaan: 12-March 05 Ahli ke- 6,834 |
aku rasa masalah utama ko kat view tu.error tu cakap dia tak bawak nilai.apa yang aku nampak adalah pada controller ko.aku tak paham kod ni.cuba ko jangan bawak lagi params id tu
CODE def viewall sara = "select hotels.hotelName, hotels.hrating_type, rooms.roomName,rooms.roomPrice from hotels, rooms where hotels.hotelNo='SRH' and rooms.hotelNo='SRH' " @rooms+Room.find_by_sql(sara, param[:id]) end try ni dulu CODE def viewall @sara = Hotel.find_by_sql("select hotels.hotelName, hotels.hrating_type, rooms.roomName,rooms.roomPrice from hotels, rooms where hotels.hotelNo='SRH' and rooms.hotelNo='SRH';") end pastu kat view ko wat cani. CODE <% @sara.each do | i | %> <%=i.hotelName%> <%=i.roomName%> <%end%> cuba dulu.aku tak compile pon.ada error jangan mara Kiriman ini telah diubahsuai oleh spirit: Mar 29 2008, 08:57 PM -------------------- Once a new technology starts rolling, if you're not part of the steamroller, you're part of the road.
- Stewart Brand - |
|
|
|
Mar 30 2008, 09:44 AM
Kiriman
#7
|
|
|
Ahli Baru Grup: Learning Kiriman: 8 Penyertaan: 27-March 08 Dari: somewhere on earth Ahli ke- 45,088 |
dah try tp error yg sm kt <% @sara.each do | i | %> sini jugak...tq
|
|
|
|
Mar 31 2008, 06:35 PM
Kiriman
#8
|
|
|
Ahli Rajin ![]() ![]() ![]() ![]() Grup: Members Kiriman: 550 Penyertaan: 12-March 05 Ahli ke- 6,834 |
peliknya..ko da cuba query direct dalam database tu.kuar tak output dia
-------------------- Once a new technology starts rolling, if you're not part of the steamroller, you're part of the road.
- Stewart Brand - |
|
|
|
Mar 31 2008, 07:38 PM
Kiriman
#9
|
|
|
Ahli Baru Grup: Learning Kiriman: 8 Penyertaan: 27-March 08 Dari: somewhere on earth Ahli ke- 45,088 |
eh...sowi ler...dah dapat dah..aku tuka2 tmpt action kt controller tuh..try2 dapat plak..huhuh...bole senyum kejap eheheh
|
|
|
|
Mar 31 2008, 10:11 PM
Kiriman
#10
|
|
|
Ahli Baru Grup: Learning Kiriman: 8 Penyertaan: 27-March 08 Dari: somewhere on earth Ahli ke- 45,088 |
salam...erm..ni ade soalan lg ler..camne erk nk select date n location serentak..aku punye code camni..
@flight = Flight.find(:all, :conditions => ["DepatureDate BETWEEN ? AND ? ", @reservdata.datestart,@reservdata.dateEnd]) --> ni mmg kuar output based on date range tu je tapi aku nk dia kuar berdasarkan date n location serentak...contohnye, kalo customer select location n date so dia akn view date n location yg berkaitan.. aku try sql tp error ( Mysql::Error: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where rooms.dateAvailable= @reservdata.datestart,@reservdata.dateEnd' at line 1: select * where rooms.dateAvailable= @reservdata.datestart,@reservdata.dateEnd ni code dia : @flight = Room.find_by_sql("select * where rooms.dateAvailable= @reservdata.datestart,@reservdata.dateEnd ;") ---> sbb aku xtau nk pggil @reservdata.datestart,@reservdata.dateEnd utk find_by_sql ni kalo gune--> @flight = Flight.find(:all, :conditions => ["DepatureDate BETWEEN ? AND ? ","locationno ? ", @reservdata.datestart,@reservdata.dateEnd, @reservdata.locationno]) --> xpat gak..just nk tmbh satu lg condition jer, error yg kuar "wrong number of bind variables (4 for 2) in: DepatureDate BETWEEN ? AND ? " camne erk.. thank you |
|
|
|
Mar 31 2008, 11:27 PM
Kiriman
#11
|
|
|
Ahli Rajin ![]() ![]() ![]() ![]() Grup: Members Kiriman: 550 Penyertaan: 12-March 05 Ahli ke- 6,834 |
bro..seriusly aku tak paham apa yang ko cuba nak explain dan nak buat.sekejap ko pakai table flight,sekjap ko pakai table room.aku poon pening
tapi apa yang dapat agak mungkin ko nk buat bila user select date range dan location,sistem ko akan display condition tersebut kan.mungkin cani kot ko nak buat CODE input type 1=datestart input type 2=dateend input type 3=location oleh kerana aku tak tau table mana ko nak pakai so aku assume ko nak pakai table flight CODE @flight= Flight.find_by-sql("select * from flights where DepartureDate between '#{params[:datestart]' and '#{params[:dateend]'} and location='#params[:location]'). tapi aku tak tau location tu datang dari celah mana.so nanti ko join table location tu skali..uhuu..aku pon main hentam je ni..kalo total wrong anggap jek ni spam..ahaha -------------------- Once a new technology starts rolling, if you're not part of the steamroller, you're part of the road.
- Stewart Brand - |
|
|
|
Apr 3 2008, 05:56 PM
Kiriman
#12
|
|
|
Ahli Baru Grup: Learning Kiriman: 8 Penyertaan: 27-March 08 Dari: somewhere on earth Ahli ke- 45,088 |
hoho..aku try cr ko mmg error la bro..but ok ler kasi aku idea..nway..nk tnye lagi nih...camne nk wat kt dlm controller kalo melibat kan checkbox/radiobutton..contoh paling senang cam kite bli tiket kapal terbang melalui airasia tuh..dia kan gune radio button tp aku nk gune check box..mm..value yg check box tu pegang adalah dr 2 table iaitu flight dan airline..so bile click je check box (1 atau 2 chek box atau lebih ok gak ler ) tu dia akn paparkan result n masuk ke dlam table br yg simpan semua value2 dr 2 table tu...fyi, aku mmg wat project reservation for airline n hotel..mm..tu je la soalan aku utk kali nih..heheh..kalo korang ade idea...
thank u |
|
|
|
Apr 3 2008, 10:16 PM
Kiriman
#13
|
|
|
Ahli Rajin ![]() ![]() ![]() ![]() Grup: Members Kiriman: 550 Penyertaan: 12-March 05 Ahli ke- 6,834 |
sori bro..aku pon sebenarnya baru gak ngan ruby ni.tapi aku tolong apa aku termampu tolong dengan pengetahuan yang tak seberapa ni.yang soalam pasal checkbox tu aku kurang jelas, value checkbox itu sendiri datang dari db atau ko assign value ko dan masok dalam db.sori sebab aku tak pernah booking tiket flight sendri, semua orang uruskan. aku tukang check-in saja:p.
berbalik soklam ko tu. aku cadangkan ko wat cani.bila user tick kat checkbox tu, ko guna ajax(kalo tanya shidi dia akan suro guna jquery) untuk retrieve data-data yang berkaitan.pastu konfirmkan baru simpan.entah betol tak pemahaman aku ni..ahaha ps: ko wat projek ngan air asia pasni leh la bagi tiket pree gi hawaii kat aku..ahahah -------------------- Once a new technology starts rolling, if you're not part of the steamroller, you're part of the road.
- Stewart Brand - |
|
|
|
Apr 4 2008, 07:43 AM
Kiriman
#14
|
|
|
Ahli Baru Grup: Learning Kiriman: 8 Penyertaan: 27-March 08 Dari: somewhere on earth Ahli ke- 45,088 |
huhuhu..xpe2 kite sesame blajo..fyi value check box tu dtg dr dbase la (2 table yg dah di joinkan)...ajax?..hohoho...selalu dgr tp x pernh tau pun camne nk wat..adeh..bole kasi pandangan x...
thank u |
|
|
|
Apr 5 2008, 07:39 AM
Kiriman
#15
|
|
|
Ahli Rajin ![]() ![]() ![]() ![]() Grup: Members Kiriman: 550 Penyertaan: 12-March 05 Ahli ke- 6,834 |
-------------------- Once a new technology starts rolling, if you're not part of the steamroller, you're part of the road.
- Stewart Brand - |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 30th August 2008 - 09:04 AM |




Mar 28 2008, 01:12 PM


