Module: V2Users::ManageRestaurantsController
- Extended by:
- ActiveSupport::Concern
- Included in:
- RestaurantsController
- Defined in:
- app/controllers/v2_users/manage_restaurants_controller.rb
Overview
typed: ignore frozen_string_literal: true
Instance Method Summary collapse
- #create ⇒ Object
- #cuisines ⇒ Object
- #owner_get_ready ⇒ Object
- #sign_up_premium ⇒ Object
- #tag_groups ⇒ Object
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/v2_users/manage_restaurants_controller.rb', line 29 def create owner = Owner.new(owner_params) phone = restaurant_params[:phone] country_id_currency = find_country_id_currency(params) new_restaurant_params = restaurant_params phone_code = country_id_currency[2].to_s == 'Singapore' ? '+65' : phone[0..2] new_restaurant_params[:phone] = "#{phone_code}#{phone[3..(phone.size)]}" restaurant = Restaurant.new(new_restaurant_params.merge(country_id: country_id_currency[0], currency_code: country_id_currency[1])) result = RestaurantService::Create.new(owner, restaurant, params, current_user).execute if result.success? OwnerMailer.owner_getstarted(result.data[:owner][:id], I18n.locale.to_s).deliver_later! render json: { data: result.data[:owner], message: 'Successfully registered.', success: true, next_url: "/#{I18n.locale}/restaurants/owner_get_ready/#{restaurant.friendly_id}" } else render json: { data: nil, message: result., success: false } end end |
#cuisines ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/controllers/v2_users/manage_restaurants_controller.rb', line 20 def cuisines cuisines = RestaurantTag.where("title_en LIKE 'Cuisine:%'").order("title_#{I18n.locale}") if cuisines.blank? render json: { data: [], message: 'Can not find cuisines', success: false } else render json: { data: cuisines, message: 'Success', success: true } end end |
#owner_get_ready ⇒ Object
52 53 54 |
# File 'app/controllers/v2_users/manage_restaurants_controller.rb', line 52 def owner_get_ready @restaurant = Restaurant.friendly.find(params.require(:id)) end |
#sign_up_premium ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/v2_users/manage_restaurants_controller.rb', line 7 def sign_up_premium title: 'Hungry Hub Reservation System Premium!!' @restaurant_type = 'premium' render 'sign_up' end |
#tag_groups ⇒ Object
13 14 15 16 17 18 |
# File 'app/controllers/v2_users/manage_restaurants_controller.rb', line 13 def tag_groups groups = RestaurantTagGroup.includes(:translations).exclude_deleted.order_by_rank my_response_cache "tag_groups:#{groups.cache_key}", :json do Oj.load(render_to_string(json: groups, each_serializer: RestaurantCpt::Serializers::TagGroupSerializer)) end end |