Last active
August 29, 2015 14:06
-
-
Save gxespino/8b65a3f4903e87cd86b6 to your computer and use it in GitHub Desktop.
Perk form bug
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
<div class="row" id="form_topnav"> | |
<div class="col-md-offset-2 col-md-8"> | |
<center> | |
<input id="pre_btn1" onclick="basic_step()" type="button" value="Basics" class="btn btn-info btn-md top-nav"> | |
<input id="next_btn1" onclick="perks_step()" type="button" value="Perks" class="btn btn-info btn-md top-nav"> | |
<input id="next_btn1" onclick="story_step()" type="button" value="Story" class="btn btn-info btn-md top-nav"> | |
<input id="next_btn2" onclick="team_step()" type="button" value="Team" class="btn btn-info btn-md top-nav"> | |
<input id="next_btn2" onclick="fund_step()" type="button" value="Funding" class="btn btn-info btn-md top-nav"> | |
</center> | |
</div> | |
</div> | |
<%= form_for @campaign, id: "msform", html: { multipart: true } do |f| %> | |
<% if @campaign.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@campaign.errors.count, "error") %> prohibited this campaign from being saved:</h2> | |
<ul> | |
<% @campaign.errors.full_messages.each do |message| %> | |
<li><%= message %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> | |
<div class="row" id="create_form"> | |
<div class="col-md-offset-2 col-md-8"> | |
<div class="panel panel-default"> | |
<div class="panel-body" id="form_panel_body"> | |
<!-- ********************* BASICS ************************ | |
********************************************************** --> | |
<fieldset id="first"> | |
<h3 class="no_spacing"><strong>Basics</strong></h3> | |
<h5>Make a good first impression: introduce your campaign objectives and entice people to learn more. This basic information will represent your campaign on your campaign page, on your campaign card, and in searches.</h5> | |
<hr> | |
<div class="form-group"> | |
<%= f.label :image, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.file_field :image, autocomplete: "on", class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :project_title, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :project_title, class: "form-control" %> | |
<h6>Your project title should be simple, specific, and memorable, and it should include the title of the creative project you're raising funds for. Avoid words like "help,” "support,” or "fund.”</h6> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :tagline, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :blurb, class: "form-control" %> | |
<h6>If you had to describe what you're creating in one tweet, how would you do it?</h6> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :Deadline, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<h5>Funding ends <%= f.text_field :funding_duration, cols: 2, rows: 3, class: "form-control funding_days" %> days from launch (60 days max)</h5> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :funding_goal, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :funding_goal, class: "form-control", placeholder: "$0 USD"%> | |
<h6>Your funding goal should be the minimum amount needed to complete the project and fulfill all rewards. Because funding is all-or-nothing, you can always raise more than your goal but never less. <br><br> If your project is successfully funded, Kickstarter will apply a 5% fee to the funds raised, and Amazon will apply credit card processing fees (about 3-5%). If funding isn't successful, there are no fees.</h6> | |
</div> | |
</div> | |
<div class="col-lg-2 pull-right"> | |
<input id="next_btn1" onclick="perks_step()" type="button" value="Continue" class="btn btn-primary btn-lg"> | |
</div> | |
</fieldset> | |
<!-- ********************* END BASICS ******************** | |
********************************************************** --> | |
<!-- ********************* PERKS ************************* | |
********************************************************** --> | |
<fieldset id="second"> | |
<h3 class="no_spacing"><strong>Perks</strong></h3> | |
<h5>Perks are incentives offered to contributors in exchange for their support. You can edit a perk until it has been claimed by a contributor and you can show up to 20 perks at a time on your campaign page.</h5> | |
<hr> | |
<div class="form-group tall"> | |
<%= f.fields_for :perks do |perk| %> | |
<%= render 'perk_fields', f: perk %> | |
<% end %> | |
<div class="form-group tall"> | |
<%= link_to_add_association "Add Perk", f, :perks, :class => "btn btn-default btn-sm" %> | |
</div> | |
</div> | |
<div class="col-lg-2 pull-right"> | |
<input id="next_btn2" onclick="story_step()" type="button" value="Continue" class="btn btn-primary btn-lg"> | |
</div> | |
<div class="col-lg-2 pull-right"> | |
<input id="pre_btn1" onclick="basic_step()" type="button" value="Previous" class="btn btn-default btn-lg"> | |
</div> | |
</fieldset> | |
<!-- ********************* END PERKS ********************* | |
********************************************************** --> | |
<!-- ********************* STORY ************************* | |
********************************************************** --> | |
<fieldset id="third"> | |
<h3 class="no_spacing"><strong>Story</strong></h3> | |
<h5>Tell potential contributors more about your campaign. Introduce yourself and provide details that will motivate people to contribute. A good pitch is compelling, informative, and easy to digest.</h5> | |
<hr> | |
<div class="form-group"> | |
<%= f.label :campaign_video, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :video_url, class: "form-control", placeholder: "http://youtube.com/watch?" %> | |
<h6>The most important thing about project videos? Making one. Projects with a video have a much higher chance of success. It doesn't need to be an Oscar contender, just be yourself and explain what you want to do. For helpful tips and a dose of inspiration, check out our post on making an awesome project video</h6> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :description, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.bootsy_area :description, class: "form-control bootsy", placeholder: | |
"<strong><h3>Short Summary</h3></strong> | |
Contributors fund ideas they can be passionate about and to people they trust. Here are some things to do | |
<ul> | |
<li>Introduce yourself and your background.</li> | |
<li>Briefly describe your campaign and why it's important to you.</li> | |
<li>Express the magnitude of what contributors will help you achieve.</li> | |
</ul> | |
Remember, keep it concise, yet personal. Ask yourself: if someone stopped reading here would they be ready to make a contribution? | |
<strong><h3>What We Need & What You Get</h3></strong> | |
Break it down for folks in more detail:<br> | |
<ul> | |
<li>Explain how much funding you need and where it's going. Be transparent and specific-people need to trust you to want to fund you.</li> | |
<li>Tell people about your unique perks. Get them excited!</li> | |
<li>Describe where the funds go if you don't reach your entire goal.</li> | |
</ul> | |
<strong><h3>Risks & Challenges</h3></strong> | |
People value your transparency. Be open and stand out by providing insight into the risks and obstacles you may face on the way to achieving your goal. | |
<ul> | |
<li>Share what qualifies you to overcome these hurdles.</li> | |
<li>Describe your plan for solving these challenges.</li> | |
</ul> | |
And that's all there is to it." %> | |
<h6>Use your project description to share more about what you’re raising funds to do and how you plan to pull it off. It’s up to you to make the case for your project.</h6> | |
</div> | |
</div> | |
<div class="col-lg-2 pull-right"> | |
<input id="next_btn2" onclick="team_step()" type="button" value="Continue" class="btn btn-primary btn-lg"> | |
</div> | |
<div class="col-lg-2 pull-right"> | |
<input id="pre_btn1" onclick="perks_step()" type="button" value="Previous" class="btn btn-default btn-lg"> | |
</div> | |
</fieldset> | |
<!-- ********************* END STORY ********************* | |
********************************************************** --> | |
<!-- ********************* TEAMS ********************* | |
********************************************************** --> | |
<fieldset id="fourth"> | |
<h3 class="no_spacing"><strong>Team</strong></h3> | |
<h5>Please provide this person's information so we can get in touch if there are any issues with the campaign. This information will not be displayed or shared publicly.</h5> | |
<hr> | |
<div class="form-group"> | |
<%= f.label :legal_first_name, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :legal_first_name, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :legal_last_name, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :legal_last_name, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :phone_number, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.telephone_field :phone_number, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :country, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :country, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :street_address, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :street_address, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :city, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :city, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :zip_code, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.number_field :zip_code, class: "form-control" %> | |
</div> | |
</div> | |
<div class="col-lg-2 pull-right"> | |
<input id="next_btn3" onclick="fund_step()" type="button" value="Continue" class="btn btn-primary btn-lg"> | |
</div> | |
<div class="col-lg-2 pull-right"> | |
<input id="pre_btn2" onclick="story_step()" type="button" value="Previous" class="btn btn-default btn-lg"> | |
</div> | |
</fieldset> | |
<!-- ********************* END TEAMS ********************* | |
********************************************************** --> | |
<!-- ********************* FUNDING *********************** | |
********************************************************** --> | |
<fieldset id="fifth"> | |
<h3 class="no_spacing"><strong>Funding</strong></h3> | |
<h5>Provide information for us to verify your account and set it up to receive payments. </h5> | |
<hr> | |
<div class="form-group"> | |
<%= f.label :photo_id, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.file_field :photo_id, autocomplete: "on", class: "form-control" %> | |
<h6>A Government issued photo id is needed to verify your identify prior to receiving funds. Don't worry if you don't have this available right now. You can verify your account with a photo id anytime prior to receiving funds. </h6> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :check_scan, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.file_field :check_scan, autocomplete: "on", class: "form-control" %> | |
<h6>Funds will be deposited into this account after your campaign is funded. </h6> | |
</div> | |
</div> | |
<div class="form-group" id="form_submit"> | |
<div class="col-lg-2 pull-right"> | |
<%= f.submit "Submit", class: "btn btn-primary btn-lg" %> | |
</div> | |
</div> | |
<div class="col-lg-2 pull-right"> | |
<input id="pre_btn3" onclick="team_step()" type="button" value="Previous" class="btn btn-default btn-lg"> | |
</div> | |
</fieldset> | |
<!-- ********************* END FUNDING ******************* | |
********************************************************** --> | |
</div> | |
</div> | |
</div> | |
</div> | |
<% 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
<div class="nested-fields"> | |
<field> | |
<div class="perk-group"> | |
<div class="form-group"> | |
<%= f.label :perk_name, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_field :name, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :pledge_amount, class: "col-lg-3 control-label" %> | |
<div class="col-lg-3"> | |
<%= f.text_field :amount, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :number_available, class: "col-lg-3 control-label" %> | |
<div class="col-lg-3"> | |
<%= f.text_field :number_available, class: "form-control" %> | |
</div> | |
</div> | |
<div class="form-group"> | |
<%= f.label :description, class: "col-lg-3 control-label" %> | |
<div class="col-lg-9"> | |
<%= f.text_area :description, class: "form-control text-area-no-resize", :size => "5x5" %> | |
</div> | |
</div> | |
</div> | |
</field> | |
<div class="perk-delete"> | |
<%= link_to_remove_association "Remove Perk", f %> | |
</div> | |
</div> | |
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
class Campaign < ActiveRecord::Base | |
belongs_to :user | |
has_many :perks | |
accepts_nested_attributes_for :perks, :reject_if => :all_blank, :allow_destroy => true | |
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" | |
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"] | |
has_attached_file :photo_id, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" | |
validates_attachment_content_type :image, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"] | |
has_attached_file :check_scan, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" | |
validates_attachment_content_type :check_scan, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"] | |
validates :image, presence: true | |
validates :video_url, presence: true | |
validates :description, presence: true | |
validates :blurb, presence: true | |
validates :project_title, presence: true | |
validates :funding_goal, presence: true | |
validates :funding_duration, presence: true | |
auto_html_for :video_url do | |
html_escape | |
image | |
youtube(:width => 640, :height => 480, :autoplay => true) | |
link :target => "_blank", :rel => "nofollow" | |
simple_format | |
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
class CampaignsController < ApplicationController | |
before_action :set_campaign, only: [:show, :edit, :update, :destroy] | |
before_action :correct_user, only: [:edit, :update, :destroy] | |
before_action :authenticate_user!, except: [:index, :show] | |
def index | |
@campaigns = Campaign.all | |
end | |
def show | |
@perks = @campaign.perks | |
end | |
def new | |
@campaign = current_user.campaigns.build | |
end | |
def edit | |
end | |
def create | |
@campaign = current_user.campaigns.build(campaign_params) | |
if @campaign.save | |
redirect_to @campaign, notice: 'Campaign was successfully created.' | |
else | |
render :new | |
end | |
end | |
def update | |
if @campaign.update(campaign_params) | |
redirect_to @campaign, notice: 'Campaign was successfully updated.' | |
else | |
render :edit | |
end | |
end | |
def destroy | |
@campaign.destroy | |
redirect_to campaigns_url, notice: 'Campaign was successfully destroyed.' | |
end | |
def show_campaign_perks | |
@perks = Perk.all | |
end | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_campaign | |
@campaign = Campaign.find(params[:id]) | |
end | |
def correct_user | |
@campaign = current_user.campaigns.find_by(id: params[:id]) | |
redirect_to campaigns_path, notice: "Not authorized to edit this campaign" if @campaign.nil? | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def campaign_params | |
params.require(:campaign).permit(:project_title, | |
:video_url, | |
:description, | |
:image, | |
:blurb, | |
:funding_duration, | |
:funding_goal, | |
:legal_first_name, | |
:legal_last_name, | |
:birthday, | |
:phone_number, | |
:street_address, | |
:country, | |
:zip_code, | |
perks_attributes: [:name, :amount, :number_available, :description, :_destroy]) | |
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
class Perk < ActiveRecord::Base | |
belongs_to :campaign | |
has_many :orders | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment