Class: ConcertoManykinds::ManykindsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ConcertoManykinds::ManykindsController
- Defined in:
- app/controllers/concerto_manykinds/manykinds_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/concerto_manykinds/manykinds_controller.rb', line 5 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 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 |
#destroy ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/concerto_manykinds/manykinds_controller.rb', line 22 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_params ⇒ Object
33 34 35 |
# File 'app/controllers/concerto_manykinds/manykinds_controller.rb', line 33 def manykind_params params.require(:manykind).permit(*ConcertoManykinds::Manykind.form_attributes) end |