Class: Calagator::EventsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Calagator::EventsController
- Includes:
- DuplicateChecking::ControllerActions
- Defined in:
- app/controllers/calagator/events_controller.rb
Instance Method Summary collapse
- #clone ⇒ Object
-
#create ⇒ Object
POST /events POST /events.xml.
- #create_or_update ⇒ Object
-
#destroy ⇒ Object
DELETE /events/1 DELETE /events/1.xml.
-
#edit ⇒ Object
GET /events/1/edit.
-
#index ⇒ Object
GET /events GET /events.xml.
-
#new ⇒ Object
GET /events/new GET /events/new.xml.
-
#search ⇒ Object
GET /events/search.
-
#show ⇒ Object
GET /events/1 GET /events/1.xml.
-
#update ⇒ Object
PUT /events/1 PUT /events/1.xml.
Methods included from DuplicateChecking::ControllerActions
#duplicates, #squash_many_duplicates
Instance Method Details
#clone ⇒ Object
103 104 105 106 107 |
# File 'app/controllers/calagator/events_controller.rb', line 103 def clone @event = Event::Cloner.clone(Event.find(params[:id])) flash[:success] = "This is a new event cloned from an existing one. Please update the fields, like the time and description." render "new" end |
#create ⇒ Object
POST /events POST /events.xml
44 45 46 47 |
# File 'app/controllers/calagator/events_controller.rb', line 44 def create @event = Event.new create_or_update end |
#create_or_update ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/calagator/events_controller.rb', line 55 def create_or_update saver = Event::Saver.new(@event, params.permit!) respond_to do |format| if saver.save format.html { flash[:success] = 'Event was successfully saved.' if saver.has_new_venue? flash[:success] += " Please tell us more about where it's being held." redirect_to edit_venue_url(@event.venue, from_event: @event.id) else redirect_to @event end } format.xml { render :xml => @event, :status => :created, :location => @event } else format.html { flash[:failure] = saver.failure render action: @event.new_record? ? "new" : "edit" } format.xml { render :xml => @event.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /events/1 DELETE /events/1.xml
81 82 83 84 85 86 87 88 |
# File 'app/controllers/calagator/events_controller.rb', line 81 def destroy @event.destroy respond_to do |format| format.html { redirect_to(events_url, :flash => {:success => "\"#{@event.title}\" has been deleted"}) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /events/1/edit
39 40 |
# File 'app/controllers/calagator/events_controller.rb', line 39 def edit end |
#index ⇒ Object
GET /events GET /events.xml
14 15 16 17 18 19 |
# File 'app/controllers/calagator/events_controller.rb', line 14 def index @browse = Event::Browse.new(params) @events = @browse.events @browse.errors.each { |error| append_flash :failure, error } render_events @events end |
#new ⇒ Object
GET /events/new GET /events/new.xml
34 35 36 |
# File 'app/controllers/calagator/events_controller.rb', line 34 def new @event = Event.new(params.permit![:event]) end |
#search ⇒ Object
GET /events/search
91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/controllers/calagator/events_controller.rb', line 91 def search @search = Event::Search.new(params) # setting @events so that we can reuse the index atom builder @events = @search.events flash[:failure] = @search. return redirect_to root_path if @search.hard_failure? render_events(@events) end |
#show ⇒ Object
GET /events/1 GET /events/1.xml
23 24 25 26 27 28 29 30 |
# File 'app/controllers/calagator/events_controller.rb', line 23 def show @event = Event.find(params[:id]) return redirect_to(@event.progenitor) if @event.duplicate? render_event @event rescue ActiveRecord::RecordNotFound => e return redirect_to events_path, flash: { failure: e.to_s } end |
#update ⇒ Object
PUT /events/1 PUT /events/1.xml
51 52 53 |
# File 'app/controllers/calagator/events_controller.rb', line 51 def update create_or_update end |