master
 1module Api
 2  module V1
 3    class TutorialsController < ApiController
 4      def index
 5        @tutorials = current_user.tutorials.page(page).per(per_page)
 6      end
 7
 8      def create
 9        @tutorial = current_user.tutorials.create!(tutorial_params)
10        current_user.tag(@tutorial, with: params[:tutorial][:tags], on: :tags)
11      end
12
13      private
14
15      def tutorial_params
16        params.require(:tutorial).permit(:url, :image_url, :heading, :description)
17      end
18    end
19  end
20end