Skip to content

Instantly share code, notes, and snippets.

$(function() {
$.each( $(".submission_user_select"), function(key, el) {
$(el).tokenInput("/teams/"+$(el).attr('data-team-id')+"/team_members.json", {
crossDomain: false,
prePopulate: $("#submission_user_id").data("pre"),
hintText: "Type a member name...",
tokenLimit: 1,
propertyToSearch: "full_name",
placeholder: "Type a member name...",
theme: "facebook",
$(function(){
$('#response_note').enableSubmitOnType();
});
jQuery.fn.enableSubmitOnType = function() {
$("input[type=submit]").attr("disabled", "disabled");
this.keyup(function(e){
var textInput = $(e.target);
var formEl = $(textInput).closest('form');
var submitButton = $(formEl).find('input[type=submit]');
class RelationshipsController < ApplicationController
before_filter :authenticate
def create
@user = User.find(params[:relationship][:followed_id])
current_user.follow!(@user)
respond_to do |format|
format.html { redirect_to @user }
format.js
end
@nickstamas
nickstamas / gist:1383099
Created November 21, 2011 16:15
Form passing empty params[]
def create
if params[:item_share] && params[:receiver] && params[:email]
user = User.find_by_email(params[:item_share][:receiver][:email])
@item = Item.create!(params[:item_share][:item])
@item_share = current_user.item_shares_given.build(:item_id => @item.id,
:share_target_user_id => user.id,
:note => params[:item_share][:note])
if @item_share.save
flash[:success] = "Item_share created!"
redirect_to root_path