diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index b0167c41..09f2611f 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -36,10 +36,9 @@ class EventsController < ApplicationController respond_to do |format| if @event.save format.html { redirect_to :root, notice: t('.ok') } - # 201 means :created - format.json { render action: 'show', status: 201, location: @event } + format.json { render action: :show, status: :created, location: @event } else - format.html { render action: 'new' } + format.html { render action: :new } status = :unprocessable_entity format.json { render json: @event.errors, status: status } end @@ -63,7 +62,7 @@ class EventsController < ApplicationController format.html { redirect_to @event, notice: t('.ok') } format.json { head :no_content } else - format.html { render action: 'edit' } + format.html { render action: :edit } status = :unprocessable_entity format.json { render json: @event.errors, status: status } end diff --git a/app/controllers/orgas_controller.rb b/app/controllers/orgas_controller.rb index 68d2813e..fb27f0db 100644 --- a/app/controllers/orgas_controller.rb +++ b/app/controllers/orgas_controller.rb @@ -27,8 +27,7 @@ class OrgasController < ApplicationController respond_to do |format| if @orga.save format.html { redirect_to @orga, notice: t('.ok') } - # 201 means :created - format.json { render action: 'show', status: 201, location: @orga } + format.json { render action: 'show', status: :created, location: @orga } else format.html { render action: 'new' } format.json { render json: @orga.errors, status: :unprocessable_entity } diff --git a/app/views/events/_form.html.haml b/app/views/events/_form.html.haml index 2423f0a5..f8d6445e 100644 --- a/app/views/events/_form.html.haml +++ b/app/views/events/_form.html.haml @@ -30,14 +30,14 @@ = f.label :address = f.text_field :address, list: :addresses %datalist#addresses - - Event.where('address is not null').group(:address).order('count(address) desc').pluck(:address).each do |address| - %option= address + - Event.where('address is not null').group(:address).order('1 desc').count.each do |r| + %option= r[0] .field.city.required = f.label :city = f.text_field :city, required: true, list: :cities %datalist#cities - - Event.group(:city).order('count(city) desc').pluck(:city).each do |city| - %option= city + - Event.group(:city).order('1 desc').count.each do |r| + %option= r[0] .field.region.required = f.label :region = render partial: '/regions/selector', locals: { f: f }