Skip to content

Instantly share code, notes, and snippets.

View kibaekr's full-sized avatar

Keith Ryu kibaekr

  • New York
  • 02:44 (UTC -04:00)
View GitHub Profile
module Ratis
class RoutePattern
attr_accessor :description, :area, :lat, :long, :point, :atisstopid, :stopid
def self.where(conditions)
#just trying to find by date for now. once this works, will add servicetype condition
date = conditions.delete(:date).to_s.upcase
module Ratis
class Area
attr_accessor :area, :description
def self.all
response = Request.get 'Getareas'
return [] unless response.success?
# GET /tracks/new
# GET /tracks/new.json
def new
@track = Track.new
@missions = @track.missions.build
respond_to do |format|
format.html # new.html.erb
@kibaekr
kibaekr / view.layouts.tracks.html.erb
Created November 24, 2012 22:50
if condition doesn't catch show page.
view/layouts/tracks.html.erb
//according to the Layout Assignment on http://api.rubyonrails.org/classes/AbstractController/Layouts.html, I created a new layout file with the same name as the controller
<!DOCTYPE html>
<html>
<head>
<title><%= content_for?(:title) ? yield(:title) : "Onvard" %></title>
<!-- [if lt IE9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"
@kibaekr
kibaekr / application.html.erb
Created November 22, 2012 10:56
yields and routes?
<body>
<%= render 'layouts/header' %>
<div class="background">
<% if current_page?(root_url) %>
<%= yield :index %>
<!-- PROBLEM: if i include the show_track, then other pages dont work -->
<% elsif current_page?(@track) %>
<%= yield :show_track %>
<% else %>
@kibaekr
kibaekr / ApplicationController.rb
Created July 9, 2012 21:19
got the damn routing to finally work!
class ApplicationController < ActionController::Base
protect_from_forgery
#session['user_return_to'] = request.url
def after_sign_in_path_for(resource)
sign_in_url = "http://localhost:3000/users/sign_in" || "http://onvard.com/users/sign_in" ||
"http://www.onvard.com/users/sign_in" #url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http')
if (request.referer == sign_in_url)
@kibaekr
kibaekr / Missions.rb
Created July 9, 2012 16:16
missions controller full
class MissionsController < ApplicationController
# GET /missions
# GET /missions.json
before_filter :store_location
before_filter :authenticate_user!, :except => [:show, :index]
def vote_for_mission
@mission = Mission.find(params[:id])
@originalpage = session[:page_a]
@kibaekr
kibaekr / ApplicationController.rb
Created July 9, 2012 12:13
session variable for request.referer doesn't actually store the url value
class ApplicationController < ActionController::Base
protect_from_forgery
#session['user_return_to'] = request.url
def after_sign_in_path_for(resource)
sign_in_url = "http://localhost:3000/users/sign_in" || "http://onvard.com/users/sign_in" ||
"http://www.onvard.com/users/sign_in" #url_for(:action => 'new', :controller => 'sessions', :only_path => false, :protocol => 'http')
if (request.referer == sign_in_url)
@kibaekr
kibaekr / Track.rb
Created June 26, 2012 08:07
Model Code for Track (post)
class Track < ActiveRecord::Base
acts_as_taggable
include PgSearch
pg_search_scope :search_by_title, :against => :title #:using => [:tsearch => {:prefix => true}], #:trigram, :dmetaphone]
pg_search_scope :search_by_weight,
:against => {
:title => 'B',
:description => 'C'
@kibaekr
kibaekr / _import_form.html.erb
Created June 6, 2012 03:57
this ruby loop doesn't work. do i need to do something to allow ruby to work in js.erb?
<%= form_tag(import_missions_path, :method => :post, :id => "import-js", :remote => true ) do |f| %>
<ul>
<% current_user.folders.find_by_order(1).missions.each do |mission| %>
<li> <%= check_box_tag "mission_ids[]", mission.id %>
<%= mission.id.to_s + ". " + mission.title %> </li>
<% end %>
</ul>
<%= submit_tag "Import ", :class => 'btn btn-primary' %>
<% end %>