diff options
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/referentials_controller.rb | 17 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 10 |
2 files changed, 16 insertions, 11 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 40e8264ce..f63abf685 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -13,13 +13,16 @@ class ReferentialsController < ChouetteController end def create - create! do |format| - build_referenial - - if !!@referential.created_from_id - flash[:notice] = t('notice.referentials.duplicate') - - format.html { redirect_to workbench_path(@referential.workbench) } + create! do |success, failure| + success.html do + if @referential.created_from_id.present? + flash[:notice] = t('notice.referentials.duplicate') + redirect_to workbench_path(@referential.workbench) + end + end + failure.html do + Rails.logger.info "Can't create Referential : #{@referential.errors.inspect}" + render :new end end end diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index b24e90ba5..5243ce56c 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -14,10 +14,12 @@ class StopAreasController < ChouetteController respond_to :html, :kml, :xml, :json respond_to :js, :only => :index - # def complete - # @stop_areas = line.stop_areas - # render :layout => false - # end + def autocomplete + scope = stop_area_referential.stop_areas.where(deleted_at: nil) + args = [].tap{|arg| 4.times{arg << "%#{params[:q]}%"}} + @stop_areas = scope.where("unaccent(name) ILIKE unaccent(?) OR unaccent(city_name) ILIKE unaccent(?) OR registration_number ILIKE ? OR objectid ILIKE ?", *args).limit(50) + @stop_areas + end def select_parent @stop_area = stop_area |
