Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop'

  • Loading branch information...
commit 23f4adcfce27ab22270f80a4448152801e96a549 2 parents 365ace8 + ca3c50d
@jordelver jordelver authored
View
6 app/controllers/noodall_poll/admin/polls_controller.rb
@@ -43,6 +43,12 @@ def destroy
redirect_to noodall_poll_admin_polls_path
end
+ def reset
+ get_poll
+ @poll.responses.delete_all
+ redirect_to noodall_poll_admin_polls_path
+ end
+
def new_response_option_form_element
if request.xhr?
render :partial => 'new_response_option_form'
View
3  app/models/noodall_poll/poll.rb
@@ -9,6 +9,7 @@ class Poll
timestamps!
many :response_options, :class => NoodallPoll::ResponseOption
+ many :responses, :class => NoodallPoll::PollResponse
validates_presence_of(:name, :question)
@@ -58,4 +59,4 @@ def remove_empty_response_options
end
end
-end
+end
View
3  app/views/noodall_poll/admin/polls/index.html.erb
@@ -12,7 +12,7 @@
<th>Name</th>
<th>Question</th>
<th>Response options</th>
- <th colspan="3">Actions</th>
+ <th colspan="4">Actions</th>
</tr>
</thead>
<tbody>
@@ -23,6 +23,7 @@
<td><%= poll.response_options ? poll.response_options.length : 0 %></td>
<td width="45"><%= link_to('Show', noodall_poll_admin_poll_path(poll), :class => 'show') %></td>
<td width="45"><%= link_to('Edit', edit_noodall_poll_admin_poll_path(poll), :class => 'edit') %></td>
+ <td width="45"><%= link_to('Reset', reset_noodall_poll_admin_poll_path(poll), :confirm => "All Poll responses will be lost\nAre you sure?", :method => :post, :class => 'reset') %></td>
<td width="45"><%= link_to('Delete', noodall_poll_admin_poll_path(poll), :confirm => 'Are you sure?', :method => :delete, :class => 'delete') %></td>
</tr>
<% end %>
View
6 lib/noodall_poll/routes.rb
@@ -11,7 +11,11 @@ def draw(app)
'polls/new_reponse_option_form_element' => 'polls#new_response_option_form_element',
:as => 'new_response_option_element'
)
- resources :polls
+ resources :polls do
+ member do
+ post 'reset'
+ end
+ end
end
View
2  lib/noodall_poll/version.rb
@@ -1,3 +1,3 @@
module NoodallPoll
- VERSION = "0.0.1"
+ VERSION = "0.0.2"
end
Please sign in to comment.
Something went wrong with that request. Please try again.