Improvements in proposal controller

`if..else` is better than unless with return.
On failed update render `edit` template and not render `new` template.
On failed save redirect to index path and not render `new` template.
Change `destory` to `withdraw`, cause `destroy` makes DELETE request when
we are updating the event record.
Check for success for save in withdraw (save can fail for reasons other than validation).
This commit is contained in:
Aditya Prakash 2016-03-24 00:24:52 +05:30
parent 10ef898a0d
commit dcb98c49f9
3 changed files with 36 additions and 34 deletions

View file

@ -87,7 +87,7 @@
method: :patch, class: 'btn btn-mini btn-success', id: "confirm_proposal_#{event.id}"
- if event.transition_possible? :withdraw
= link_to 'Withdraw', conference_program_proposal_path(@conference.short_title, event.id), method: :delete,
= link_to 'Withdraw', withdraw_conference_program_proposal_path(@conference.short_title, event.id), method: :patch,
data: { confirm: 'Are you sure you want to withdraw this proposal?' }, class: 'btn btn-mini btn-warning',
id: "delete_proposal_#{event.id}"
- if event.state == 'withdrawn' || event.state == 'rejected'