Skip to content

Instantly share code, notes, and snippets.

View jrbruce's full-sized avatar

jrbruce

  • San Francisco Bay Area
View GitHub Profile
# User Model
class User < ActiveRecord::Base
has_one :account, :validate => true, :autosave => true
devise :database_authenticatable, :registerable, :lockable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :first_name, :last_name, :username, :email, :password,
:password_confirmation, :remember_me, :account_attributes
validates_presence_of :first_name, :last_name#, :username
@jrbruce
jrbruce / js_code.js
Created February 15, 2011 19:06
This is the client's page that will embed our signup iframe.
// Need to grab hash from page here
// Append hash to iFrame src url
// Set path to the iframe file
var filePath = 'http://www.google.com';
// Setup the iframe target
var iframe='<iframe id="frame" name="widget" src ="#" width="100%" height="1" marginheight="0" marginwidth="0" frameborder="no" scrolling="no"></iframe>';
// Write the iframe to the page
document.write(iframe);
# spec/helpers/application_helper_spec.rb
require 'spec_helper'
describe ApplicationHelper do
describe "#logo" do
it "image tag should point to logo.png" do
helper.logo.should =~ /logo.png/i
end
end
#admin_routes_spec.rb
require "spec_helper"
describe "Admin Routes" do
describe "GET '/admin'" do
it "should block access if not on www" do
{ :get => "http://foo.example.com/admin" }.should_not be_routable
end
# helpers/application_helper.rb
module ApplicationHelper
def setup_user(user)
user.build_account unless user.account
user
end
end
# app/models/account_owner.rb
class AccountOwner < ActiveRecord::Base