Skip to content

Instantly share code, notes, and snippets.

View kibaekr's full-sized avatar

Keith Ryu kibaekr

  • Fountain
  • San Francisco, CA
View GitHub Profile
<%= form_for @syllabus, :html => { :class => "form-horizontal" } do |f| %>
<% if @syllabus.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@syllabus.errors.count, "error") %> prohibited this syllabus from being saved:</h2>
<ul>
<% @syllabus.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
@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 %>
@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 / 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 / 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 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 / 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 / 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"
# 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
module Ratis
class Area
attr_accessor :area, :description
def self.all
response = Request.get 'Getareas'
return [] unless response.success?