Matt Hodan matthodan

View uploader_command
1
rails g uploader Photo
View Gemfile
1 2
gem 'mini_magick'
gem 'carrierwave'
View jobs_controller.rb
1 2 3 4 5 6 7 8 9
class JobsController < ApplicationController
before_filter :require_user
 
ssl_required :index, :new, :create, :update, :destroy, :destroy_all
 
respond_to :html, :only => [:index, :new, :create, :destroy, :destroy_all]
respond_to :json, :only => [:index, :create, :update, :destroy]
 
[... omitted ...]
View gist:722758
1 2 3
<%= form_for @user do |f| %>
<%= f.error_message_on :user_not_happy_and_broke %>
<% end %>
View gist:722751
1 2 3 4 5 6 7 8 9 10
class User < ActiveRecord:Base
validate :user_is_happy_and_broke
 
private
def user_is_happy_and_broke
if self.state_of_mind != 'happy' || self.fiscal_status != 'broke'
errors.add :user_not_happy_and_broke, 'User must be happy and broke to continue'
end
end
end
View gist:722744
1 2 3 4
<%= form_for @user do |f| %>
<%= f.text_field :name %>
<%= f.error_message_on :name %>
<% end %>
View gist:722743
1
<%= error_messages_for :user %>
View ruby_private_access.rb
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env ruby
 
class Parent
private
def name
'Mommy'
end
end
 
class Child < Parent
View payments_controller.rb
1 2 3 4 5 6 7 8 9 10
credit_card = {
:type => '[cc type, e.g. 'visa']',
:number => '[cc number, from test account]',
:verification_value => '123',
:month => '[expiration month, from test account]',
:year => '[expiration year, from test account]',
:first_name => '[first name, can be anything]',
:last_name => '[last name, can be anything]',
:street_1 => '[street address, can be anything]',
:city => '[city, can be anything]',
View production.rb
1 2 3 4 5 6 7 8 9
# Setup ActiveMerchant for production mode with Paypal Website Payments Pro
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :production
::GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(
:login => '[Add PayPal API login here]',
:password => '[Add PayPal API password here]',
:signature => '[Add PayPal API signature here]'
)
end
Something went wrong with that request. Please try again.