Refactoring Venue, Lodgings und Rooms

#385
This commit is contained in:
Chrisbr 2014-07-31 12:20:04 +02:00
parent 518e1cc62b
commit 5fe99dd041
26 changed files with 352 additions and 130 deletions

View file

@ -1,19 +1,54 @@
class Admin::RoomsController < ApplicationController
before_filter :verify_organizer
before_action :set_room, only: [:edit, :update, :destroy]
before_action :set_conference
def show
render :rooms_list
def index
@rooms = @conference.rooms
end
def new
@room = @conference.rooms.build
end
def edit
end
def create
@room = @conference.rooms.build(room_params)
if @room.save
redirect_to admin_conference_rooms_path(@conference.short_title), notice: 'Room was successfully created.'
else
flash[:alert] = "A error prohibited this Rooms from being saved: #{@room.errors.full_messages.join('. ')}."
render :new
end
end
def update
if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_rooms_path(
conference_id: @conference.short_title),
notice: 'Rooms were successfully updated.')
if @room.update(room_params)
redirect_to admin_conference_rooms_path(@conference.short_title), notice: 'Room was successfully updated.'
else
redirect_to(admin_conference_rooms_path(
conference_id: @conference.short_title),
notice: 'Room update failed.')
flash[:alert] = "A error prohibited this Rooms from being saved: #{@room.errors.full_messages.join('. ')}."
render :edit
end
end
def destroy
@room.destroy
redirect_to admin_conference_rooms_path, notice: 'Room was successfully destroyed.'
end
private
def set_conference
@conference = Conference.find_by(short_title: params[:conference_id])
end
def set_room
@room = Room.find(params[:id])
end
def room_params
params[:room]
end
end