/
techgrant
/
ourresource
Обзор
Документация
Войти
/
techgrant
/
ourresource
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
app/controllers/specialists_controller.rb
93 строки
2 KB
grant88
asdf
17 янв 2013, 02:23
17 янв 2013, 02:23
42e28ca
Код
Авторство
О чём код?
class SpecialistsController < ApplicationController # GET /specialists # GET /specialists.json before_filter :check_login def index @specialists = Specialist.all respond_to do |format| format.html # index.html.erb format.json { render json: @specialists } end end # GET /specialists/1 # GET /specialists/1.json def show @specialist = Specialist.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @specialist } end end # GET /specialists/new # GET /specialists/new.json def new @specialist = Specialist.new respond_to do |format| format.html # new.html.erb format.json { render json: @specialist } end end # GET /specialists/1/edit def edit @specialist = Specialist.find(params[:id]) end # POST /specialists # POST /specialists.json def create @specialist = Specialist.new(params[:specialist]) respond_to do |format| if @specialist.save @arr = params[:procedures][:id] @arr.each_index do |i| if i!=0 SpecialistsProcedures.create(:procedure_id => @arr[i], :specialist_id => @specialist.id) ProceduresSpecialists.create(:procedure_id => @arr[i], :specialist_id => @specialist.id) end end format.html { redirect_to @specialist, notice: 'Specialist was successfully created.' } format.json { render json: @specialist, status: :created, location: @specialist } else format.html { render action: "new" } format.json { render json: @specialist.errors, status: :unprocessable_entity } end end end # PUT /specialists/1 # PUT /specialists/1.json def update @specialist = Specialist.find(params[:id]) respond_to do |format| if @specialist.update_attributes(params[:specialist]) format.html { redirect_to @specialist, notice: 'Specialist was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @specialist.errors, status: :unprocessable_entity } end end end # DELETE /specialists/1 # DELETE /specialists/1.json def destroy @specialist = Specialist.find(params[:id]) @specialist.destroy respond_to do |format| format.html { redirect_to specialists_url } format.json { head :no_content } end end end