Skip to content

Instantly share code, notes, and snippets.

@ornerymoose
ornerymoose / textbook_controller.rb
Created Mar 26, 2012
Gmaps4rails gem-Issue with map not being displayed, minimum distance is being calculated fine
View textbook_controller.rb
def show
@textbook = Textbook.find(params[:id])
@this_user = User.find_by_id(session[:user_id])
@textbook.user_textbook_statuses.each do |attribute|
@map = Map.new(:to_location_id => attribute.user.location_id, from_location_id:
@this_user.location_id)
@from_address = @map.from_location.as_json(:only => [:latitude, :longitude])
@ornerymoose
ornerymoose / application.css
Created Mar 26, 2012
Application.js file for using gmaps4rails gem
View application.css
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
@ornerymoose
ornerymoose / textbooks_controller.rb
Created Mar 27, 2012
Error Message: nil cannot be coerced into float
View textbooks_controller.rb
def show
@textbook = Textbook.find(params[:id])
@this_user = User.find_by_id(session[:user_id])
@textbook.user_textbook_statuses.each do |attribute|
@map = Map.new(:to_location_id => attribute.user.location_id, :from_location_id =>
@this_user.location_id)
@from_address = @map.from_location.as_json(:only => [:latitude, :longitude])
@to_address = @map.to_location.as_json(:only => [:latitude, :longitude])
View maps_controller.rb
def show
@map = Map.find(params[:id])
loc_one = @map.to_location_id.as_json(:only => [:latitude, :longitude])
loc_two = @map.from_location_id.as_json(:only => [:latitude, :longitude])
dave_loc = [ loc_one, loc_two]
dave_loc = dave_loc.map do |marker|
{ lng: marker['longitude'], lat: marker['latitude'] }
end
map = [ dave_loc ]
@mapz = map.to_json
@ornerymoose
ornerymoose / maps_controller.rb
Created Apr 2, 2012
Cannot convert string into integer error message
View maps_controller.rb
def show
@map = Map.find(params[:id])
loc_one = @map.from_location_id.as_json(:only => [:latitude, :longitude])
loc_two = @map.to_location_id.as_json(:only => [:latitude, :longitude])
dave_loc = [ loc_one, loc_two ]
dave_loc = dave_loc.map do |marker|
{ lng: marker['longitude'], lat: marker['latitude'] }
end
map = [ dave_loc ]
@mapz = map.to_json
View show.html.erb
<ul id="markers_list">
<%= gmaps({
"map_options" => { "auto_zoom" => true },
"markers" => { "data" => @markers, "options" => { "draggable" => true} }
})
%>
</ul>
#if I just have "zoom" and change the value it does not change anything.
View Gemfile
source "http://rubygems.org"
gem "rails", "3.0.7"
gem "active_hash"
gem "dynamic_form"
gem "formtastic"
gem "geocoder", ">= 1.0.1"
gem "humanizer"
gem 'httparty'
@ornerymoose
ornerymoose / application.js
Created May 1, 2012
Doing the opposite of what I want it to do
View application.js
//the text should initially be hidden, then when you click the link, it should show the text.
//weird thing is: for another section of the website, it works just fine. Thoughts?
//this is the one that works fine:
$("#about.faq .question h3 a").click(function(event){
event.preventDefault();
$(this).parents(".question").children(".answer").slideToggle(100);
$(this).toggleClass("active");
@ornerymoose
ornerymoose / bulk.html.haml
Created May 2, 2012
FAQ Page is Working Correctly.
View bulk.html.haml
= render :partial => "shared/sidebar_nav"
#about.static
.page-header
%h1 Bulk Buying
%section.content
%p.cursive Give the Gift of Choice!
%p CouponTrade now offers access to over 300 nationally recognized gift card brands. We have established direct relationships with key distributors to ensure that you receive maximum discounts.
%p If you're looking to upload Daily Deals and Gift Cards by the boatload, just give one of our listing representatives a shout and we'll walk you through the process.
%p.bold
@ornerymoose
ornerymoose / test.html
Created May 4, 2012
Not recognizing css reference
View test.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="static/bulk_order_form_style.scss" />
</head>
<body>
<div class="container">
...content