Commit 5891161b095cfce15044093883963ee02022f527

Authored by Rafael Manzo
1 parent 4dc573e8

set_project sets the project_image as well

Showing 1 changed file with 1 additions and 4 deletions   Show diff stats
app/controllers/projects_controller.rb
@@ -32,20 +32,16 @@ class ProjectsController < ApplicationController @@ -32,20 +32,16 @@ class ProjectsController < ApplicationController
32 def show 32 def show
33 set_project 33 set_project
34 @project_repositories = @project.repositories 34 @project_repositories = @project.repositories
35 - @project_image = ProjectImage.find_by_project_id(@project.id)  
36 end 35 end
37 36
38 # GET /projects/1/edit 37 # GET /projects/1/edit
39 # GET /projects/1/edit.json 38 # GET /projects/1/edit.json
40 def edit 39 def edit
41 set_project 40 set_project
42 - @project_image = ProjectImage.find_by_project_id(@project.id)  
43 - #@project_image ? @project_image.check_no_image : ProjectImage.new  
44 end 41 end
45 42
46 def update 43 def update
47 set_project 44 set_project
48 - @project_image = ProjectImage.find_by_project_id(@project.id)  
49 image_url = project_params.delete(:image_url) 45 image_url = project_params.delete(:image_url)
50 if @project.update(project_params) && @project_image.update(url: image_url) 46 if @project.update(project_params) && @project_image.update(url: image_url)
51 redirect_to(project_path(@project.id)) 47 redirect_to(project_path(@project.id))
@@ -70,6 +66,7 @@ class ProjectsController < ApplicationController @@ -70,6 +66,7 @@ class ProjectsController < ApplicationController
70 # Use callbacks to share common setup or constraints between actions. 66 # Use callbacks to share common setup or constraints between actions.
71 def set_project 67 def set_project
72 @project = Project.find(params[:id]) 68 @project = Project.find(params[:id])
  69 + @project_image = ProjectImage.find_by_project_id(@project.id)
73 end 70 end
74 71
75 # Never trust parameters from the scary internet, only allow the white list through. 72 # Never trust parameters from the scary internet, only allow the white list through.