Class: ConcertoManykinds::ManykindsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/concerto_manykinds/manykinds_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /schedules POST /schedules.json



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/concerto_manykinds/manykinds_controller.rb', line 56

def create
  @manykind = Manykind.new(manykind_params)
  auth! :action => :update, :object => @manykind.template
  respond_to do |format|
    if @manykind.save
      format.html { redirect_to @manykind, notice: 'Kind was successfully created.' }
      #format.json { render json: @manykind, status: :created, location: @manykind }
      format.json do 
        item_html = render_to_string(:partial => 'concerto_manykinds/templates/item', :object => @manykind, :formats => [:html])
        render json: { :field_id => @manykind.field.id, :item_html => item_html }, status: :created, location: @manykind 
      end
    else
      format.html { render action: "new" }
      format.json { render json: @manykind.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /schedules/1 DELETE /schedules/1.json



97
98
99
100
101
102
103
104
105
106
# File 'app/controllers/concerto_manykinds/manykinds_controller.rb', line 97

def destroy
  @manykind = Manykind.find(params[:id])
  auth! :action => :update, :object => @manykind.template
  @manykind.destroy
  
  respond_to do |format|
    format.html { redirect_to manykindsengine.manykinds_url }
    format.json { head :no_content }
  end
end

#manykind_paramsObject



108
109
110
# File 'app/controllers/concerto_manykinds/manykinds_controller.rb', line 108

def manykind_params
  params.require(:manykind).permit(*ConcertoManykinds::Manykind.form_attributes)
end