This file contains hidden or 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
# check that user is logged in | |
def require_user | |
logger.info "Require User" | |
if current_user.nil? | |
session[:link_back] = request.url | |
redirect_to login_path | |
false | |
end | |
end | |
def require_user_no_linkback |
This file contains hidden or 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
# check that user is logged in | |
def require_user | |
if current_user.nil? | |
session[:link_back] = request.url | |
redirect_to login_path | |
false | |
end | |
end |
This file contains hidden or 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
<h1>MenuItems#index</h1> | |
<style> | |
.column { width: 170px; float: left; padding-bottom: 100px; } | |
.portlet { margin: 0 1em 1em 0; } | |
.portlet-header { margin: 0.3em; padding-bottom: 4px; padding-left: 0.2em; } | |
.portlet-header .ui-icon { float: right; } | |
.portlet-content { padding: 0.4em; } | |
.ui-sortable-placeholder { border: 1px dotted black; visibility: visible !important; height: 50px !important; } |
This file contains hidden or 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
#starting at line 243 | |
def feeds_into_timescales(feeds) | |
# convert timescale (minutes) into seconds | |
seconds = params[:timescale].to_i * 60 | |
# get floored time ranges | |
logger.info "Original Start time is " + feeds.first.created_at.to_s | |
logger.info "Original End time is " + feeds.last.created_at.to_s | |
start_time = get_floored_time(feeds.first.created_at, seconds) | |
end_time = get_floored_time(feeds.last.created_at, seconds) | |
logger.info "start_time = " + start_time.to_s + " & end_time is " + end_time.to_s |
This file contains hidden or 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 ContactMethod < ActiveRecord::Base | |
validates_presence_of :name | |
def self.select_options | |
descendants.map { |c| c.to_s }.sort | |
end | |
end | |
class Phone < ContactMethod | |
end |
This file contains hidden or 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
#This form "should" create a new contact and a new group_contact record. What I really | |
# want to do is to add an existing contact to a group. But can't figure out | |
# how to build a form_for that will let me do that. | |
# | |
# If I were creating my own form, I'd just put the group_id in a hidden field and let | |
# the user pick a contact from a select. Then I'd post to a groups_controller | |
# to add the contact to group.contacts. | |
# | |
# I'm just not seeing how to do that in a form_for | |
# |
This file contains hidden or 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
routes.rb | |
================= | |
resources :groups do | |
member do | |
post 'join' | |
put 'add_contact' | |
end | |
end | |
When I do "bundle exec rake routes" I get "add_contact_group" -> /groups/:id/add_contact |
This file contains hidden or 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
#ruby 1.9.2 | |
require 'json' | |
class Item | |
def initialize(name, description ) | |
@name = name | |
@description = description | |
end | |
def to_json(*a) | |
{"name" => @name, "description" => @description}.to_json(*a) |
This file contains hidden or 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
public class Thing { | |
private String title ; | |
private List<Thing> children ; | |
public Thing(String title) { this.title = thing ); | |
// getters and settors accordingly | |
} | |
List<Thing> things = new ArrayList<Thing>() ; | |
things.add(new Thing("One")); |
This file contains hidden or 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
<html> | |
<head> | |
<script src="javascripts/jquery-1.6.2.js" type="text/javascript" ></script> | |
<script type="text/javascript"> | |
$(function() { | |
$('input').click(function(event) { | |
alert("This worked ..." + event.type); | |
}); | |
$("#content").html("<input type='button' value='Loaded later'/>"); | |
}); |