Sha256: ed56ba58b496258624118cf7ae3e521457a7094c7c265c541b273337398c2b16
Contents?: true
Size: 1.1 KB
Versions: 11
Compression:
Stored size: 1.1 KB
Contents
require_dependency "hicube/application_controller" module Hicube class ContentsController < BaseController before_action :load_resource, except: [ :create, :index, :new ] before_filter :load_resources, :only => [ :index, ] # Must be called after load_recource filter. before_filter :check_resource_params, :only => [ :create, :update, ] def update logger.debug "Updating Pages with #{params}" @content.update_attributes content_params @content.save! respond_to do |format| format.json { render json: true } end rescue Mongoid::Errors::Validations => e respond_to do |format| format.json { render json: false } end end private def content_params params.require(:content).permit(:name, :body) end # Nested attributes are currently not handled in basecontroller def load_resource @page = Hicube::Page.unscoped.find(params[:page_id]) @content = @page.content.find_or_create_by(name: params[:id]) end def load_resources end end end
Version data entries
11 entries across 11 versions & 1 rubygems