Class: ProjectsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/projects_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #api_authenticate!, #authenticated_via_token?, #current_project, #expire_revision!, #followed_projects, #no_cache, #oauth_authorize!, #read_revision, #require_login, #return_or_cache_revision!, #revision, #token_authenticate!, #unfurling?, #with_current_project

Methods included from UrlHelper

#feature_path, #link_to_project_feature

Instance Method Details

#createObject



32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/projects_controller.rb', line 32

def create
  @project = Project.new(project_attributes)

  if @project.save
    redirect_to teams_path, notice: 'Project was successfully created.'
  else
    flash.now[:error] = @project.errors[:base].join("\n")
    render action: "new"
  end
end

#destroyObject



65
66
67
68
69
70
# File 'app/controllers/projects_controller.rb', line 65

def destroy
  @project = Project.find_by_slug!(params[:id])
  @project.destroy

  redirect_to projects_url
end

#editObject



26
27
28
29
# File 'app/controllers/projects_controller.rb', line 26

def edit
  @project = Project.find_by_slug!(params[:id])
  @title = "Edit #{@project.name}"
end

#indexObject



7
8
9
10
# File 'app/controllers/projects_controller.rb', line 7

def index
  @title = "Projects"
  @projects = Project.preload(:team).unretired
end

#newObject



18
19
20
21
22
23
# File 'app/controllers/projects_controller.rb', line 18

def new
  @title = "New Project"
  @team = Team.find params[:team_id]
  @project = @team.projects.build
  authorize! :create, @project
end

#retireObject



58
59
60
61
62
# File 'app/controllers/projects_controller.rb', line 58

def retire
  @project = Project.find_by_slug!(params[:id])
  @project.retire!
  redirect_to projects_path, notice: "#{@project.name} was successfully retired."
end

#showObject



13
14
15
# File 'app/controllers/projects_controller.rb', line 13

def show
  redirect_to projects_path
end

#updateObject



44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/projects_controller.rb', line 44

def update
  @project = Project.find_by_slug!(params[:id])

  @project.props.merge! project_attributes.delete(:props) if project_attributes.key?(:props)

  if @project.update_attributes(project_attributes)
    redirect_to projects_path, notice: 'Project was successfully updated.'
  else
    flash.now[:error] = @project.errors[:base].join("\n")
    render action: "edit"
  end
end