Использование ROR 2.3.8.
Вот мой код:
class CitiesController < ApplicationController
def show
...
end
def western
@city = City.find(params[:id])
@spots = Spot.paginate(
:conditions => ["(city=? or state=?) and country=? and shop_type=?", "#{@city.name}", "#{@city.name}", @city.country, "Places"],
:page => params[:page],
:per_page => 20,
:order => 'rating_average DESC'
)
end
def middle-east
@city = City.find(params[:id])
@spots = Spot.paginate(
:conditions => ["(city=? or state=?) and country=? and shop_type=?", "#{@city.name}", "#{@city.name}", @city.country, "Food"],
:page => params[:page],
:per_page => 20,
:order => 'rating_average DESC'
)
end
def asian
@city = City.find(params[:id])
@spots = Spot.paginate(
:conditions => ["(city=? or state=?) and country=? and shop_type=?", "#{@city.name}", "#{@city.name}", @city.country, "Accommodation"],
:page => params[:page],
:per_page => 20,
:order => 'rating_average DESC'
)
end
end
Я создал western.html.erb
, middle-east.html.erb
, asian.html.erb
и _shops.html.erb
.
Итак, первые три в основном пустые, но выдают _shops.html.erb
, чтобы я не мог перекодировать макет представления.
Есть ли лучший способ написания контроллера?
Спасибо!