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
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 %> |
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
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; | |
} |
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
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 |
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 Photo < ActiveRecord::Base | |
attr_accessible :shared, :user_id, :image, :remote_image_url | |
belongs_to :user | |
mount_uploader :image, ImageUploader | |
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
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> |
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 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 |
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
<% 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"> |
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
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 |