Description:
fix problem edit page
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r590:0ef720704122 - - 2 files changed: 4 inserted, 4 deleted

@@ -12,13 +12,13
12
12
13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
14 verify :method => :post, :only => [ :destroy,
14 verify :method => :post, :only => [ :destroy,
15 :create, :quick_create,
15 :create, :quick_create,
16 :do_manage,
16 :do_manage,
17 :do_import,
17 :do_import,
18 - :update ],
18 + ],
19 :redirect_to => { :action => :index }
19 :redirect_to => { :action => :index }
20
20
21 def show
21 def show
22 @problem = Problem.find(params[:id])
22 @problem = Problem.find(params[:id])
23 end
23 end
24
24
@@ -68,20 +68,20
68 @description = @problem.description
68 @description = @problem.description
69 end
69 end
70
70
71 def update
71 def update
72 @problem = Problem.find(params[:id])
72 @problem = Problem.find(params[:id])
73 @description = @problem.description
73 @description = @problem.description
74 - if @description == nil and params[:description][:body]!=''
74 + if @description.nil? and params[:description][:body]!=''
75 @description = Description.new(params[:description])
75 @description = Description.new(params[:description])
76 if !@description.save
76 if !@description.save
77 flash[:notice] = 'Error saving description'
77 flash[:notice] = 'Error saving description'
78 render :action => 'edit' and return
78 render :action => 'edit' and return
79 end
79 end
80 @problem.description = @description
80 @problem.description = @description
81 - elsif @description!=nil
81 + elsif @description
82 if !@description.update_attributes(params[:description])
82 if !@description.update_attributes(params[:description])
83 flash[:notice] = 'Error saving description'
83 flash[:notice] = 'Error saving description'
84 render :action => 'edit' and return
84 render :action => 'edit' and return
85 end
85 end
86 end
86 end
87 if params[:file] and params[:file].content_type != 'application/pdf'
87 if params[:file] and params[:file].content_type != 'application/pdf'
@@ -1,9 +1,9
1 <h1>Editing problem</h1>
1 <h1>Editing problem</h1>
2
2
3 - <%= form_tag({action: 'update', id: @problem},multipart: true) do %>
3 + <%= form_for @problem,url:{action: 'update'},html: {multipart: true} do %>
4 <%= render :partial => 'form' %>
4 <%= render :partial => 'form' %>
5 <%= submit_tag 'Edit' %>
5 <%= submit_tag 'Edit' %>
6 <% end %>
6 <% end %>
7
7
8 <%= link_to 'Show', :action => 'show', :id => @problem %> |
8 <%= link_to 'Show', :action => 'show', :id => @problem %> |
9 <%= link_to 'Back', :action => 'list' %>
9 <%= link_to 'Back', :action => 'list' %>
You need to be logged in to leave comments. Login now