Updated Location and loction categories to pass ids

This commit is contained in:
saurabhbhatia 2013-10-03 17:30:05 +08:00
parent 746bcbed96
commit 44f5a98a69
2 changed files with 7 additions and 3 deletions

View File

@ -42,7 +42,8 @@ class Panel::Location::BackEnd::LocationCategoriesController < OrbitBackendContr
name_en = category.name
I18n.locale = :zh_tw
name_zh_tw = category.name
@data << { name_en: name_en, name_zh_tw: name_zh_tw, category_id: category.id.to_s, location_link: "http://ntue.tp.rulingcom.com/panel/location/back_end/locations/get_categorywise_locations" }
category_id = category.id.to_s
@data << { name_en: name_en, name_zh_tw: name_zh_tw, category_id: category_id, location_link: "http://ntue.tp.rulingcom.com/panel/location/back_end/locations/get_categorywise_locations?category_id[]=#{category_id}"}
end
render :json => JSON.pretty_generate({location_category: @data})

View File

@ -75,12 +75,15 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController
end
def get_categorywise_locations
location_infos = LocationInfo.where(:location_category_id => params[:category_id])
@data = Array.new
@category_id = params[:category_id].first
location_infos = LocationInfo.where(:location_category_id => @category_id)
@data = Array.new
location_infos.each do |location|
picurl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.url}"
thumburl = location.file.blank? ? '' : "http://#{request.host_with_port + location.file.thumb.url}"
@data << { name: location.name,
pic_url: picurl,
thumb_url: thumburl,