favouriteshandler 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/favorites.rb +13 -53
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a51d903cf1f0efa8df8e7ff42533fffb8482b5cd986a68fe0dd5667e2a9faab
|
|
4
|
+
data.tar.gz: c51740c9f10f3605086db87854a945930734b568eb69310951da52da03971e74
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d720899e89dc9ac33a8ef36080385ace0c69038790582ac6b2fd532c4c3bd001e2d754292dc0fab44f1edd8fa1954dc3544034db8cf0b4ad60c8f10bfe99d8c
|
|
7
|
+
data.tar.gz: eabd2f0e4272faa3e18106be4295e672285fb2e073d43269db643b49e477efa7385abc3b012d98739f74451c07574383294cf00d79936f121656ccc7b7b9eeeb
|
data/lib/favorites.rb
CHANGED
|
@@ -1,65 +1,25 @@
|
|
|
1
|
+
#this modules facilitates the favorite functionality
|
|
1
2
|
module Favorites
|
|
2
3
|
|
|
3
|
-
def hotellikehandler
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
@hotel = Hotel.find(params[:hotel_id])
|
|
7
|
-
liked = LikedHotel.where(user_id: @user, hotel_id: @hotel.id)
|
|
5
|
+
def addtofav(userclmnname,userid, itemclmnname,itemid, tablename) # will add the item to the favorites list
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
else
|
|
15
|
-
id= liked.ids
|
|
16
|
-
LikedHotel.destroy(id)
|
|
17
|
-
redirect_back fallback_location: root_path
|
|
18
|
-
end
|
|
7
|
+
likeit = Hash.new
|
|
8
|
+
columntype = userclmnname
|
|
9
|
+
likeit[columntype] = userid
|
|
10
|
+
columntype = itemclmnname
|
|
11
|
+
likeit[columntype] = itemid
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@user = current_user.id
|
|
25
|
-
@restaurant = Restaurant.find(params[:restaurant_id])
|
|
26
|
-
liked = LikedRestaurant.where(user_id: @user, restaurant_id: @restaurant.id)
|
|
27
|
-
|
|
28
|
-
if(liked == [])
|
|
29
|
-
likeit = {user_id: @user, restaurant_id: @restaurant.id}
|
|
30
|
-
@liked_restaurant = LikedRestaurant.new(likeit)
|
|
31
|
-
|
|
32
|
-
@liked_restaurant.save
|
|
33
|
-
redirect_back fallback_location: root_path
|
|
34
|
-
|
|
35
|
-
else
|
|
36
|
-
id= liked.ids
|
|
37
|
-
LikedRestaurant.destroy(id)
|
|
38
|
-
redirect_back fallback_location: root_path
|
|
39
|
-
|
|
40
|
-
end
|
|
13
|
+
@liked_hotel = tablename.new(likeit)
|
|
14
|
+
@liked_hotel.save
|
|
15
|
+
redirect_back fallback_location: root_path
|
|
41
16
|
|
|
42
17
|
end
|
|
43
18
|
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
@user = current_user.id
|
|
47
|
-
@transport = Transport.find(params[:transport_id])
|
|
48
|
-
liked = LikedTransport.where(user_id: @user, transport_id: @transport.id)
|
|
49
|
-
|
|
50
|
-
if(liked == [])
|
|
51
|
-
likeit = {user_id: @user, transport_id: @transport.id}
|
|
52
|
-
@liked_transport = LikedTransport.new(likeit)
|
|
53
|
-
|
|
54
|
-
@liked_transport.save
|
|
55
|
-
redirect_back fallback_location: root_path
|
|
56
|
-
|
|
57
|
-
else
|
|
58
|
-
id= liked.ids
|
|
59
|
-
LikedTransport.destroy(id)
|
|
60
|
-
redirect_back fallback_location: root_path
|
|
19
|
+
def removefav(likedid, tablename)# will remove the item from the favorites list
|
|
61
20
|
|
|
62
|
-
|
|
21
|
+
tablename.destroy(likedid)
|
|
22
|
+
redirect_back fallback_location: root_path
|
|
63
23
|
|
|
64
24
|
end
|
|
65
25
|
|