Skip to content

Instantly share code, notes, and snippets.

function stripeResponseHandler(status, response) {
if (response.error) {
// show the errors on the form
$(".payment-errors").text(response.error.message);
$(".submit-button").removeAttr("disabled");
} else {
var form$ = $("#payment-form");
// token contains id, last4, and card type
var token = response['id'];
// insert the token into the form so it gets submitted to the server
<% form_tag("/stripe", :method => "POST", :remote => true), :id => "payment-form" %>
<div class="form-row">
<label>Card Number</label>
<input type="text" size="20" autocomplete="off" class="card-number"/>
</div>
<div class="form-row">
<label>CVC</label>
<input type="text" size="4" autocomplete="off" class="card-cvc"/>
</div>
<div class="form-row">
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
end
Enter a message (optional) and address. If you don't have an address, enter an email and we'll email that person for their address.
<br />
<%= form_for(@postcard, :remote => true) do |f| %>
<% if @postcard.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@postcard.errors.count, "error") %> prohibited this postcard from being saved:</h2>
<ul>
<% @postcard.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<form accept-charset="UTF-8" action="https://graph.facebook.com/me/photos" data-remote="true" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="AAAEey81RDnIBAHunatjryN7EBGwc1ZBuUzHwbgRP1vWcSplZB1zLp1euPuTGjmoxcaWYfHDXmZAu5koohKgzynzDCglHZCcZD"></div>
<div class="field">
<input id="access_token" name="access_token" type="hidden" value="AAAEey81RDnIBAHunatjryN7EBGwc1ZBuUzHwbgRP1vWcSplZB1zLp1euPuTGjmoxcaWYfHDXmZAu5koohKgzynzDCglHZCcZD">
</div>
<div class="field">
<input id="url" name="url" type="hidden" value="https://airbrush.s3.amazonaws.com/uploads/photo/image/350/586dad001c884238aa07d6c36aeb2a16.jpg?AWSAccessKeyId=AKIAIRNYWSHC76SCRLFQ&amp;Signature=dKw4fmnMC1XSGMDG7bV%2BfkaNli0%3D&amp;Expires=1340577199">
</div>
<div class="field" id="tagfield">
<input id="tags" name="tags" type="hidden" value="boo!">
</div>
class Photo < ActiveRecord::Base
attr_accessible :shared, :user_id, :image, :remote_image_url
belongs_to :user
mount_uploader :image, ImageUploader
end
def aviarycreate
@photo = Photo.new
@photo.user_id = current_user.id if current_user
@photo.remote_image_url = params[:url]
@photo.save
respond_to do |format|
format.json { render json: @photo }
end
end
success: function(msg) {
var id = msg.id;
var url = '/share?id=' + id;
$('#share').html("<a class='iframe' href='/share?id="+id+"'>some stuff</a>");
fancybox().window.location.href=url;
}
Hello from /share!
<br/>
<% if @photo %>
<%= image_tag @photo.image.url %>
<h2>Post to Facebook!</h2>
<%= form_tag('https://graph.facebook.com/'+@identifier+'/photos', :remote => true, :authenticity_token => current_user.fb_token) do %>
<div class="field">
<%= hidden_field_tag 'access_token', current_user.fb_token %>
Hello from /share!
<br/>
<% if @photo %>
<%= image_tag @photo.image.url %>
<h2>Post to Facebook!</h2>
<%= form_tag('https://graph.facebook.com/me/feed', :remote => true, :authenticity_token => current_user.fb_token) do %>
<div class="field">
<%= hidden_field_tag 'picture', @photo.image.url %>