Saya bingung, mohon bantuan. Saya mo tampilkan data yang ada di tabel lain yang 
terelasi antar tabel. Berikut Keterangannya :
   
  
--------------------------------------------------------------------------------------
  Location : app/models/kamar.rb  
  
--------------------------------------------------------------------------------------
  class Kamar < ActiveRecord::Base
    belongs_to :hotel
   
  ...
   
  def self.find_all_in_kamar(hotel)
    hotel = Hotel.find_by_name(hotel)
    self.find :all, :conditions => "id_hotel = #{Hotel.id}"
  end
   
  ...
   
  
--------------------------------------------------------------------------------------
  Location : db/migrate/kamar.rb  
  
--------------------------------------------------------------------------------------
  class CreateKamars < ActiveRecord::Migration
  def self.up
    create_table :kamars do |t|
      t.column :id_hotel, :string, :limit => 8
      ...
      end
        
        execute 'ALTER TABLE kamars ADD CONSTRAINT fk_kamars_hotels
    FOREIGN KEY ( id_hotel ) REFERENCES hotels( id ) ON DELETE CASCADE'
    ...
    
    end
   
  
--------------------------------------------------------------------------------------
   
  Gimana caranya supaya supaya di view/kamar/show.rhtml saya bisa menampilkan 
informasi semua data hotel yang memiliki id hotel sesuai dengan id_hotel pada 
tabel kamar. Apa yang harus saya tulis di :
   
  class KamarController < ApplicationController
   
  ....
    def show
    @kamar = Kamar.find(params[:id])
       ?? Apa yang harus saya tulis disini utk menampilkan data hotel??
     end
  ....
   
  Saya sudah coba ini dan berikut pesan pesan error mereka (T_T)
   
  -----------------------------------
  Experimen pertama
  ----------------------------------
  def show
    @kamar = Kamar.find(params[:id])
    @hotel = Hotel.find(:all, :conditions => "id = '[EMAIL PROTECTED]'" )
 end   
   
  --------------------------------------------
  Experimen pertama && Error
  --------------------------------------------
   
   NoMethodError in KamarController#show
   
  You have a nil object when you didn't expect it!
The error occurred while evaluating nil.id_hotel
   
   
  Hiks.. banyak experimennya sampe takut kepanjangan... PLEASE ID-RUBY PIMP MY 
CODING. sekalian kalo boleh sama coding buat show.rhtml nya. 
  [-o< Pleaseeee...  

       
---------------------------------
Bergabunglah dengan orang-orang yang berwawasan, di bidang Anda di Yahoo! 
Answers

[Non-text portions of this message have been removed]

Kirim email ke