Skip to content

Commit 3668375

Browse files
committed
Bugfix : Correctly displays bookings in the Home page of the user
1 parent d533abd commit 3668375

File tree

5 files changed

+643
-22
lines changed

5 files changed

+643
-22
lines changed

app/controllers/booking_controller.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/controllers/bookings_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ def find_by_user
9898

9999
@bookings = Booking.where('user_id=?',params[:id])
100100

101-
render :json => @bookings;
101+
render :json => @bookings.to_json(:include => [:user,:hotel])
102102
end
103103
end

app/models/booking.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
class Booking < ActiveRecord::Base
22

3-
4-
attr_accessor :checkinDate
5-
attr_accessor :checkoutDate
6-
attr_accessor :creditCardNumber
7-
attr_accessor :crediaCardType
8-
attr_accessor :creditCardName
9-
attr_accessor :creditCardExpiryMonth
10-
attr_accessor :creditCardExpiryYear
11-
attr_accessor :smoking
12-
attr_accessor :beds
13-
attr_accessor :user
14-
attr_accessor :hotel
15-
163
belongs_to :user, :class_name => 'User', :foreign_key => 'user_id'
174
belongs_to :hotel, :class_name => 'Hotel', :foreign_key => 'hotel_id'
185

app/models/user.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
class User < ActiveRecord::Base
22

33
has_many :bookings, :dependent => :destroy
4+
5+
def to_json(options = {})
6+
7+
options[:except] ||= [:password]
8+
super(options)
9+
end
410
end

0 commit comments

Comments
 (0)