Class: Iconly::ProjectsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/iconly/projects_controller.rb', line 22

def create
  @project = current_user.projects.build(project_params)

  if @project.save
    redirect_to project_path(@project),
                notice: '<i class="iconly-baby mr-05"></i> Great, a new project was created!'
  else
    render :new
  end
end

#destroyObject



52
53
54
55
# File 'app/controllers/iconly/projects_controller.rb', line 52

def destroy
  @project.destroy
  redirect_to projects_url, notice: '<i class="iconly-baby mr-05"></i> Project is gone to the bin.'
end

#editObject



19
20
# File 'app/controllers/iconly/projects_controller.rb', line 19

def edit
end

#generate_fontObject



42
43
44
45
46
47
48
49
50
# File 'app/controllers/iconly/projects_controller.rb', line 42

def generate_font
  if (zip_file = Project::Downloader.new(@project).call)
    send_file zip_file
  else
    flash[:error] = '<i class="iconly-baby2 mr-05"></i> '\
                    'Sorry an error occurred generating the font, please try again.'
    redirect_to project_path(@project)
  end
end

#indexObject



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

def index
  @projects = ProjectIcon.all_projects(current_user.id, params[:q])
end

#newObject



15
16
17
# File 'app/controllers/iconly/projects_controller.rb', line 15

def new
  @project = Project.new
end

#showObject



11
12
13
# File 'app/controllers/iconly/projects_controller.rb', line 11

def show
  @packages = Icon.all_packages(current_user.id, params[:q])
end

#updateObject



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

def update
  if @project.update(project_params)
    redirect_to project_path(@project),
                notice: '<i class="iconly-baby mr-05"></i> Awsome, project updated all right!'
  else
    render :edit
  end
end