This repository has been archived by the owner on Apr 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Embadge::App.controllers :votes do | ||
|
||
get :new, map: '/changes/:id/vote/new' do | ||
@change = BadgeChange.find params[:id] | ||
if is_logged_in? | ||
@vote = Vote.new badge_change: @change, user: current_user | ||
render 'new' | ||
else | ||
redirect url(:static, :index) | ||
end | ||
end | ||
|
||
post :create, map: '/changes/:id/vote/create' do | ||
if is_logged_in? | ||
@vote = Vote.new(params[:vote]) | ||
@change = BadgeChange.find params[:id] | ||
@vote.badge_change = @change | ||
@vote.user = current_user | ||
|
||
if @vote.save | ||
redirect(url(:badges, :show, id: @change.badge.id)) | ||
else | ||
flash.now[:error] = "Nope" | ||
render 'votes/new' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Helper methods defined here can be accessed in any controller or view in the application | ||
|
||
module Embadge | ||
class App | ||
module VotesHelper | ||
# def simple_helper_method | ||
# ... | ||
# end | ||
end | ||
|
||
helpers VotesHelper | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
= f.error_messages | ||
%div.form-group | ||
= f.label :comment | ||
= f.text_area :comment, class: 'form-control' | ||
|
||
%div.form-group | ||
= f.submit "Submit", class: 'btn btn-default' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%h2 Vote | ||
= flash_tag(:error) | ||
= form_for @vote, url(:votes, :create, id: @change.id), id: 'new_vote' do |f| | ||
= partial 'votes/form', locals: {f: f} | ||
|
||
%a{href: url(:badges, :show, id: @change.badge.id)} Back to badge |