Sha256: 6de4c56062640f71b684c4ccf43ff90c8126d31e7c4bcc0ae390d9c4269727a6
Contents?: true
Size: 1.44 KB
Versions: 4
Compression:
Stored size: 1.44 KB
Contents
require_dependency "front_end_builds/application_controller" module FrontEndBuilds class AppsController < ApplicationController before_filter :set_app , :only => [:show, :destroy] def index apps = App.includes(:recent_builds) respond_with_json({ apps: apps.map(&:serialize), builds: apps.map(&:recent_builds) .flat_map(&:to_a) .map(&:serialize) }) end def show respond_with_json({ app: @app.serialize, builds: @app.recent_builds.map(&:serialize) }) end def create @app = FrontEndBuilds::App.new( use_params(:app_create_params) ) if @app.save! respond_with_json( { app: @app.serialize }, location: nil ) else respond_with_json( { errors: @app.errors }, status: :unprocessable_entity ) end end def destroy if @app.destroy respond_with_json( { app: { id: @app.id } }, location: nil ) else respond_with_json( {errors: @app.errors}, status: :unprocessable_entity ) end end private def set_app @app = FrontEndBuilds::App.find(params[:id]) end def app_create_params_rails_3 params[:app].slice(:name) end def app_create_params_rails_4 params.require(:app).permit( :name ) end end end
Version data entries
4 entries across 4 versions & 1 rubygems