Method: ReservesController#create
- Defined in:
- app/controllers/reserves_controller.rb
#create ⇒ Object
POST /reserves POST /reserves.json
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'app/controllers/reserves_controller.rb', line 159 def create @reserve = Reserve.new(reserve_params) @reserve.set_user if current_user.has_role?('Librarian') unless @reserve.user @reserve.user = @user end else if @reserve.user != current_user if @user != current_user access_denied; return end end end respond_to do |format| if @reserve.save @reserve.transition_to!(:requested) format.html { redirect_to @reserve, notice: t('controller.successfully_created', model: t('activerecord.models.reserve')) } format.json { render json: @reserve, status: :created, location: reserve_url(@reserve) } else format.html { render action: "new" } format.json { render json: @reserve.errors, status: :unprocessable_entity } end end end |