I am generating routes and responding to it dynamically by looking at the enum defined in the model. Is this safe and is there more proper method?
# Place
enum post_type: [:restaurant, :bar, :chill]
# routes
scope '/places' do
get '/:category', to: 'places#index', constraints: { category: Regexp.new( Place.post_types.keys.join("|") ) }
end
# places_controller
def index
if Place.respond_to? parmas[:category]
@places = Place.send(params[:category]).order(:created_at).limit(10)
end
end