Skip to content

Instantly share code, notes, and snippets.

View scottmagdalein's full-sized avatar

Scott Magdalein scottmagdalein

View GitHub Profile
class Applicant < ActiveRecord::Base
attr_accessible :avatar_url, :email, :facebook_url, :google_plus_url, :linkedin_url, :name, :phone, :phys_address, :position_id, :phase_id, :resume_url, :search_url, :twitter_url, :website_url
validates :name, :presence => true
validates :phone, :presence => true
validates :email, :presence => true
validates :phys_address, :presence => true
validates_numericality_of :position_id :on => :create
validates_numericality_of :phase_id :on => :create
@scottmagdalein
scottmagdalein / gist:3041125
Created July 3, 2012 17:16
applicants_controller#create
def create
@applicant = @position.applicants.new(params[:applicant])
@applicant.phase_id = @position.phases.order(:sort_order).first.id
respond_to do |format|
if @applicant.save
format.html { redirect_to @position, notice: 'Applicant was successfully created.' }
format.json { render json: @applicant, status: :created, location: @applicant }
else
format.html { render action: "new" }
@scottmagdalein
scottmagdalein / gist:3055561
Created July 5, 2012 18:36
index of applicants by name
</table>
<hr/>
<h1>Listing applicants</h1>
<table>
<tr>
<th>Name</th>
<th></th>
@scottmagdalein
scottmagdalein / gist:3063463
Created July 6, 2012 23:57
likes_controller#create
def create
@like = Like.new(params[:like])
@like = @applicant.likes.new(params[:likes])
@like.user_id = current_user.id
respond_to do |format|
if @like.save
format.html { redirect_to @like, notice: 'Like was successfully created.' }
format.json { render json: @like, status: :created, location: @like }
else
@scottmagdalein
scottmagdalein / gist:3063470
Created July 6, 2012 23:59
applicants_controller#show
def show
@applicant = Applicant.find(params[:id])
@comments = @applicant.comments.includes(:user)
@comment = @applicant.comments.new
@like = @applicant.likes.new
respond_to do |format|
format.html # show.html.erb
format.json { render json: @applicant }
end
@scottmagdalein
scottmagdalein / gist:3063485
Created July 7, 2012 00:01
applicants/show.html.erb for "likes"
<h1>Likes</h1>
<% @comments.count == 0 %>
<p>Nobody likes this person. Sad, eh?</p>
<% else %>
<div>
<p><%= likes.count %> likes</p>
</div>
<% end %>
@scottmagdalein
scottmagdalein / gist:3083290
Created July 10, 2012 13:36
setting position for application url
private
def set_position
if @current_company
@position = @current_company.positions.find(params[:position_id])
else
@position = Position.find(params[:position_id])
end
end
@scottmagdalein
scottmagdalein / applicants_controller.rb
Created July 10, 2012 13:42
setting position for application url (with ternary)
private
def set_position
if @current_company
@position = @current_company.positions.find(params[:position_id])
else
@position = Position.find(params[:position_id])
end
end
private
@scottmagdalein
scottmagdalein / gist:3178346
Created July 25, 2012 20:15
users_controller
def new
@user = User.new(params[:user])
end
def create
@user = User.new(params[:user])
if params[:key].present?
invite = Invite.find_by_key(params[:key])
end
@scottmagdalein
scottmagdalein / gist:3228651
Created August 1, 2012 16:47
output from failed aws-sdk install
Scotts-MacBook-Air:picdigest scottmagdalein$ gem install aws-sdk
Fetching: uuidtools-2.1.3.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing aws-sdk:
ERROR: Failed to build gem native extension.
/Users/scottmagdalein/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for libxml/parser.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more