Skip to content

Instantly share code, notes, and snippets.

@jonpaul
jonpaul / admin_user.rb
Created October 13, 2011 15:10
make new admin users without assigning them a password
after_create { |admin| admin.send_reset_password_instructions }
def password_required?
new_record? ? false : super
end
@jonpaul
jonpaul / _form.html.erb
Created October 10, 2011 18:13
Multiple file uploads--
<%= form_for :vehicle_listing_images, :html => { :multipart => true } do |f| %>
<%= hidden_field_tag :listing_id, @listing_id %>
<div id="file_upload_area">
</div>
<% end %>
<div id="image-container">
<button id="primary_photo" class="btn right"><strong>Select Primary photo</strong></button>
<input type="hidden" name="vehicle_listing[primary_photo_id]" value="<%= @listing.primary_photo_id %>" id="primary_photo_id" />
<ul id="images">
require 'csv'
class ListingsController < ApplicationController
before_filter :login_required, :except => [:show, :index]
def index
@listings = session[:map_fields][:mapped_headers]
end
def new
@listing = Listing.new
def new
end
def create
user = User.authenticate(params[:login], params[:password])
if user
session[:user_id] = user.id
redirect_to_target_or_default root_url, :notice => "Logged in successfully."
else
flash.now[:alert] = "Invalid login or password."
= f.input :mapping_#{somehow_indicate_this_is_@import_header[0]}, :as => :select, :collection => @mdm_defaults
%span= import_headers
E194: No alternate file name to substitute for '#': :r!echo '* {^@ padding: 0px;^@ margin: 0px;^@}^@^@html {^@ background: white;^@}^@* {^@ padding: 0px;^
@ margin: 0px;^@}^@^@html {^@ background: white;^@}^@^@body {^@ font: 13pt "Myriad Pro", Helvetica;^@ margin: 5px 10app/assets/stylesheets/partials/_page.
scss 0px 10app/assets/stylesheets/partials/_page.scss;^@ height: 100app/assets/stylesheets/partials/_page.scss;^@ padding: 30px;^@ -moz-border-radius: 3px;
^@ -webkit-border-radius: 3px;^@}^@^@h1 {^@ margin-bottom: 20px;^@}^@^@nav {^@ margin: 10px 0px 10px 0px;^@}^@^@a {^@ color: #74CC00;^@}^@^@textarea {^@
padding: 3px;^@ margin-top: 5px;^@ margin-bottom: 5px;^@}^@^@input[type=file] {^@ margin-top: 10px;^@ margin-bottom: 10px;^@}^@^@.flash {^@ padding: 10px
;^@ -moz-border-radius: 10px;^@ -webkit-border-radius: 10px;^@ font-weight: bold;^@}^@^@#notice {^@ background: #85FF00;^@ color: black;^@}^@^@#alert {^@
background: #FF3444;^@}^@^@ul#tickets {^@ padding: 15px;^@ list-st
@jonpaul
jonpaul / gist:1247041
Created September 28, 2011 05:14
:reg
"" * {^J padding: 0px;^J margin: 0px;^J}^J^Jhtml {^J background: white;^J}
"0 * {^J padding: 0px;^J margin: 0px;^J}^J^Jhtml {^J background: white;^J}
"1 colorscheme solarized^J
"2 ^J
"3 let g:solarized_termcolors=256^J set t_Co=16^J set background=dark
"4 )
"5 true |
"6 unconfirmed |
"7 alse
"8 if
var staffs = new Array();
var staff_to_services = new Array();
var arr = new Array();
staffs.push( new Array(null, 'Choose a staff member', null) );
staffs.push( new Array(0, 'Any', 0) );
@jonpaul
jonpaul / signing_in.feature
Created September 27, 2011 18:00
Cuke a boolean
Feature: Signing in
In order to use the site
As a user
I want to be able to sign in
Scenario: Signing in via confirmation
Given there are the following users:
| email | password | unconfirmed |
| [email protected] | password | true |
And "[email protected]" opens the email with subject "Confirmation instructions"
@jonpaul
jonpaul / application.rb
Created September 21, 2011 18:03 — forked from bsodmike/application.rb
Modified config/application.rb to print out initialization points for Rails 3.1
require File.expand_path('../boot', __FILE__)
require 'rails/application'
require 'rails/engine'
module Rails
class Application < Engine
def initializers
init = Bootstrap.initializers_for(self) #BOOTSTRAP
init += super #RAILTIES
init += Finisher.initializers_for(self) #FINISHER