Skip to content

Instantly share code, notes, and snippets.

@coderforhire
Created November 9, 2012 03:07
Show Gist options
  • Save coderforhire/4043457 to your computer and use it in GitHub Desktop.
Save coderforhire/4043457 to your computer and use it in GitHub Desktop.
<%= form_for(@job, :class=>"form-horizontal") do |f| %>
<% if @job.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@job.errors.count, "error") %> prohibited this job from being saved:</h2>
<ul>
<% @job.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="control-group">
<div class="controls">
<%= f.text_field :quantity, :class => "input-xlarge", :placeholder => "Quantity" %>
</div>
</div>
<div class="control-group">
<div class="controls">
<%= f.select :shirt_quality, ["Standard", "Ring Spun"], :class => "input-xlarge" %>
</div>
</div>
<div class="control-group">
<div class="controls">
<%= f.select :turn_around, ["Rush!", "3-5 Days", "5-8 Days", "8-12 Days", "12-16 Days", "I am in no rush man, a month or two works."], :class => "input-xlarge" %>
</div>
</div>
<h5>Attach artwork (optional)</h5>
<%= f.file_field :art %>
<div class="actions">
<%= f.submit "Get Bids!", :class => "btn btn-success" %>
</div>
<% end %>
class Job < ActiveRecord::Base
belongs_to :customer
attr_accessible :quantity, :shirt_quality, :turn_around, :art, :art_file_name
self.per_page = 10
has_attached_file :art,
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => "/:style/:id/:filename"
end
~
def create
@job = Job.new(params[:job])
@job.customer_id = current_user.id
respond_to do |format|
if @job.save
format.html { redirect_to current_user, notice: 'Thanks for using shirtloop.com for your t-shirt needs!' }
format.json { render json: @job, status: :created, location: @job }
else
format.html { redirect_to current_user }
format.json { render json: @job.errors, status: :unprocessable_entity }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment