Trouble of table relations

environment: Ruby 1.9.2 Rails 3.0.9 win7-64 MySQL 5.1.53

HI, I’m working on a project. It has three tables and there are those name and relations.

"room_type" 1 to many "guest" 1 to many "reservation"

I need to access data from reservation model. It works on the rails console by following command.

"res =Reservation.find(1)"

but in the page, it says "null" result.


def show         @res=Reservation.find(params[:id]) end

Views:   <%= %>

Could somebody tell me what’s going on ?

Read the error carefully and work out what it is that is nil. If you cannot work it out read the Rails Guide on debugging which will show various ways of finding out what is going on. In particular you can use ruby-debug to break into your code before the failing line and inspect the data to see what the problem is. If you still cannot work it out post the error message and stack trace here.