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
When a user signs up they are directed to a page that asks them to enter in their profile info | |
if they are a shipper or a carrier. I am unsure what to put in the new and create actions of the user_steps controller since I am creating two separate objects for the same controller. The actions for creating both of these objects should be exactly the same. |
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 RegistrationsController < Devise::RegistrationsController | |
def create | |
build_resource | |
if resource.save | |
if resource.active_for_authentication? | |
set_flash_message :notice, :signed_up if is_navigational_format? | |
sign_in(resource_name, resource) | |
respond_with resource, :location => after_sign_up_path_for(resource) |
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
<%= form_for(@load) do |f| %> | |
<%= f.error_messages %> | |
<%= f.fields_for :destinations do |builder| %> | |
<%= render "destination_fields", :f => builder %> | |
<% end %> | |
<p><%= link_to_add_fields " Add Destination", f, :destinations %></p> | |
<% end %> | |
_destination_fields.html.erb |
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
def index | |
@facets = Load.facets( | |
(params[:trucks]), | |
:page => (params[:page] || 1), | |
:per_page => 25, | |
:geo => degrees_to_radians(@location), | |
:with => { "@geodist" => 0.0..miles_to_meters(params[:radius].to_i) }, | |
:sort_mode => :expr, | |
:order => sort_by_select(params[:sort]) | |
) |
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
Models with their associations | |
class Reservation < ActiveRecord::Base | |
belongs_to :load | |
has_one :bid | |
end | |
class Load < ActiveRecord::Base | |
has_many :bids, :dependent => :delete_all | |
has_one :reservation |
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
Here is the test I have written: | |
// Another factory is created before this with the same address | |
it "should not call the geocoding method but should grab data from the database" do | |
@dest3 = FactoryGirl.create(:destination) | |
@dest3.should_not_receive(:geocoding) | |
end | |
// This method should fail but it passes | |
def find_coordinates |
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
Here is an example record from the database before I have added a bid: | |
SELECT "loads".* FROM "loads" WHERE "loads"."id" = $1 LIMIT 1 [["id", 25]] | |
=> #<Load id: 25, commodity: "Coca-Cola", price: #<BigDecimal:103fb82c8,'0.4E3',9(18)>, weight: 30000, notes: "", created_at: "2012-04-17 22:41:53", updated_at: "2012-04-17 22:41:53", distance: 2733.36707093163, truck_type: "53' Dry Van", latitude: 0.651560856964623, longitude: -2.12983434097684, user_id: 5, delta: false, current_asking_price: nil> | |
Then we create a bid on that load with the following log: | |
Started POST "/loads/25/bids" for 127.0.0.1 at 2012-04-19 22:07:53 -0400 | |
Processing by BidsController#create as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"iHCqQR68t9mrVZ3y5r3/ZMSZY++ZckIAJYwb2GGD3gg=", "bid"=>{"bid_price"=>"200", "questions"=>""}, "commit"=>"Create Bid", "load_id"=>"25"} | |
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 15 LIMIT 1 |
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
function parse_git_branch () { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
NO_COLOUR="\[\033[0m\]" | |
PS1="$GREEN\[[TC]$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ " |
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
------------------------------- | |
The code for the contact form | |
------------------------------- | |
<div id='contact-box' class="group"> | |
<div class="span6 clear"> | |
<form action="/" method="post" class="well"> | |
<label for="name">Your Name:</label> | |
<input type="text" name="name" class="span4" placeholder="John Smith..."> | |
<label for="email">Your email address:</label> |
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
the contact form | |
========================================================= | |
<div id='contact-box' class="group"> | |
<div class="span6 clear"> | |
<form action="/contact" method="post" class="well"> | |
<label for="name">Your Name:</label> | |
<input type="text" class="span4" placeholder="John Smith..."> | |
<label for="email">Your email address:</label> | |
<input type="email" class="span4" placeholder="[email protected]"> |
NewerOlder