Sha256: 7505312a606b31f3bcce0c7b6076da210ee530cf5b7de10bd340243165809950
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
class TasksController < ApplicationController include Applicat::Mvc::Controller::Resource before_filter :build_resource, only: [:new, :create] before_filter :resource, only: [:show, :edit, :update, :destroy] load_and_authorize_resource respond_to :html, :js, :json def index @story = Story.find(params[:story_id]) @project = @story.project @tasks = @story.custom_tasks @tasks = @tasks.paginate(page: params[:page], per_page: 25) @twitter_sidenav_level = 5 end def show @hide_sidebar = true begin raise NotImplementedError if @project.product_id.blank? render "products/types/#{@project.product.class.name.split('Product::').last.tableize.singularize}/tasks/show" rescue NotImplementedError, ActionView::MissingTemplate render 'show' end end def new end def create if @task.save redirect_to story_tasks_path(@story), notice: t('tasks.create.successful') else render 'new' end end def edit end def update if @task.update(params[:task]) redirect_to( edit_task_path(@task), notice: t('tasks.update.successful') ) end end def destroy @task.destroy redirect_to story_tasks_path(@story), notice: t('general.form.destroyed') end def resource @task = Task.find(params[:id]) unless @task || !params[:id].present? @story = @task.story unless @story || !@task @project = @story.project @task end def resource=(value); @task = value; end def parent @story end private def build_resource @story = find_parent Task::PARENT_TYPES, action_name == 'create' ? :task : nil @project = @story.project @task = @story.tasks.new({ story_id: @story.id }.merge(params[:task] || {})) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
voluntary-0.7.1 | app/controllers/tasks_controller.rb |