Skip to content

Commit

Permalink
Adding updated and fixed files issue alaashafaee#211
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Fadel authored and Mohamed Fadel committed Apr 22, 2014
1 parent 408ff4f commit b0444b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tutor/app/controllers/hints_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class HintsController < ApplicationController

@@answer_id = nil

# [Delete a Hint - Story 4.21]
# This action takes the hint id, removes it from the database
# and then redirects the user to the edit page accompanied
# with a "Hint deleted" message.
# Parameters:
# params[:id]: The current hint's id
# Returns:
# none
# Author: Mohamed Fadel
def destroy
hint = Hint.find_by_id(params[:id])
hint.destroy
flash[:success_deletion] = "Hint deleted."
redirect_to :controller => 'model_answers', :action => 'edit', :id => @@answer_id
end
end
7 changes: 7 additions & 0 deletions tutor/app/views/model_answers/_index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--Add delete button to the edit view in model answers
Author: Mohamed Fadel-->

<th style = "width:20%">Delete</th>

<td><%= button_to "Delete", {controller: :hints, action: :destroy, id: hint1.id},
:method => :delete, class: 'btn btn-primary btn-xs' %></td>

0 comments on commit b0444b2

Please sign in to comment.