Commit dd05d88121ee083af5ddfeb9ac5728acc49cdf32
1 parent
4f95873b
Exists in
colab
and in
4 other branches
Different behaviour for project image not provided
Showing
3 changed files
with
5 additions
and
20 deletions
Show diff stats
app/controllers/projects_controller.rb
@@ -40,7 +40,7 @@ class ProjectsController < ApplicationController | @@ -40,7 +40,7 @@ class ProjectsController < ApplicationController | ||
40 | def edit | 40 | def edit |
41 | set_project | 41 | set_project |
42 | @project_image = ProjectImage.find_by_project_id(@project.id) | 42 | @project_image = ProjectImage.find_by_project_id(@project.id) |
43 | - @project_image ? @project_image.check_no_image : ProjectImage.new | 43 | + #@project_image ? @project_image.check_no_image : ProjectImage.new |
44 | end | 44 | end |
45 | 45 | ||
46 | def update | 46 | def update |
app/models/project_image.rb
1 | class ProjectImage < ActiveRecord::Base | 1 | class ProjectImage < ActiveRecord::Base |
2 | - | ||
3 | belongs_to :project | 2 | belongs_to :project |
4 | - before_save :check_url | ||
5 | - | ||
6 | - def check_no_image | ||
7 | - if !self.blank? | ||
8 | - if self.image_url == "no-image-available.png" | ||
9 | - self.image_url = "" | ||
10 | - end | ||
11 | - end | ||
12 | - end | ||
13 | - | ||
14 | - def check_url | ||
15 | - if self.image_url.blank? | ||
16 | - self.image_url = "no-image-available.png" | ||
17 | - end | ||
18 | - end | ||
19 | - | ||
20 | - | ||
21 | end | 3 | end |
app/views/projects/show.html.erb
@@ -2,8 +2,11 @@ | @@ -2,8 +2,11 @@ | ||
2 | <div class="page-header"> | 2 | <div class="page-header"> |
3 | <div class="media"> | 3 | <div class="media"> |
4 | <a class="pull-left"> | 4 | <a class="pull-left"> |
5 | - <% if @project_image %> | 5 | + <% if @project_image && !@project_image.image_url.empty? %> |
6 | <%= image_tag "#{@project_image.image_url}", size:"64x64" %> | 6 | <%= image_tag "#{@project_image.image_url}", size:"64x64" %> |
7 | + <% else %> | ||
8 | + <span class="glyphicon glyphicon-picture" aria-hidden="true"></span> | ||
9 | + No image available | ||
7 | <% end %> | 10 | <% end %> |
8 | </a> | 11 | </a> |
9 | <div class="media-body"> | 12 | <div class="media-body"> |