Sha256: 1b4614a98dddf8f1baab2cb4a3e2dc1006f28c4383ebe376bea0c6e45b776a78

Contents?: true

Size: 800 Bytes

Versions: 12

Compression:

Stored size: 800 Bytes

Contents

module Admin
  class ApiContentsController < ActionController::Base
  
    include Locomotive::Routing::SiteDispatcher
    
    before_filter :require_site
    
    before_filter :set_content_type
  
    def create
      @content = @content_type.contents.build(params[:content])

      respond_to do |format|
        if @content.save
          format.json { render :json => { :content => @content } }
        else
          format.json { render :json => { :content => @content, :errors => @content.errors } }
        end
      end
    end
    
    protected
  
    def set_content_type
      @content_type = current_site.content_types.where(:slug => params[:slug]).first      
      render :json => { :error => 'Api not enabled'} and return false unless @content_type.api_enabled
    end
  
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
locomotive_cms-0.0.3.3 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.3.1 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.9 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.8 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.7 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.6 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.5 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.4 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.3 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.2 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2.1 app/controllers/admin/api_contents_controller.rb
locomotive_cms-0.0.2 app/controllers/admin/api_contents_controller.rb