Skip to content

Instantly share code, notes, and snippets.

View aamax's full-sized avatar

Allen Maxwell aamax

  • aaMaxWorks Engineering, LLC
  • Draper, Utah USA
View GitHub Profile
rails new ptsspree20_static_test
cd ptsspree20_static_test
echo "ruby-1.9.3" >.ruby-version
echo "ptsspree20_static_test" >.ruby-gemset
rvm gemset delete ptsspree20_static_test
rvm gemset create ptsspree20_static_test
rvm gemset use ptsspree20_static_test
echo "gem 'spree', '2.0.0'" >> Gemfile
@aamax
aamax / application.rb
Created August 24, 2013 04:09
bootstrap menu expanding under page contents when page is small (responsive design issue) not sure why but if i make the page small and then click on the button that accesses the collapsed menu, the menu expands but does not push the page contents down, it just renders below the existing page contents.
<!DOCTYPE html>
<html ng-app="mthosts">
<head>
<title>mysite<%= @title.nil? ? "" : " | #{@title}" %></title>
<%= stylesheet_link_tag "application", :media => "all" %>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com//twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
@aamax
aamax / controller snippet
Created September 12, 2013 19:32
Rails: multi select control with multiple items pre selected
def edit
@publication = Publication.find(params[:id])
@recipients = @publication.users
end
def edit
@publication = Publication.find(params[:id])
@recipients = @publication.users
@users = User.first
end
@aamax
aamax / minitest output
Created September 19, 2013 00:49
minitest not running My tests were working ok yesterday - been working on expanding them. all of a sudden, when i run them I get the following results. any idea what I've done? not sure what other info would be needed.
$ rake minitest:all
NOTICE: CREATE TABLE will create implicit sequence "roles_id_seq" for serial column "roles.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "roles_pkey" for table "roles"
NOTICE: CREATE TABLE will create implicit sequence "shift_types_id_seq" for serial column "shift_types.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "shift_types_pkey" for table "shift_types"
NOTICE: CREATE TABLE will create implicit sequence "shifts_id_seq" for serial column "shifts.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "shifts_pkey" for table "shifts"
NOTICE: CREATE TABLE will create implicit sequence "sys_configs_id_seq" for serial column "sys_configs.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "sys_configs_pkey" for table "sys_configs"
NOTICE: CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id"
@aamax
aamax / model and controller
Last active December 28, 2015 23:08
trying to add a field to an activerecord model to set some values at run time.
# ----------------------
class MyObj < ActiveRecord::Base
attr_accessor :i_can_select
end
# ----------------------
class MyController < ApplicationController
def index
@list = MyObj.all
@aamax
aamax / solution_aamax_dave_hacket
Created September 24, 2014 20:41
URUG 20140923 meeting results: CSV file parsing
# the code is unfinished as of yet, this is as far as we got during the meeting
class Parser
def initialize filename, delimiter=","
@fhandle = File.open(filename, 'r')
@delim = delimiter
@header = []
@arr_val = []
line_str = @fhandle.readline
@header = parse_row(line_str)
end
@aamax
aamax / towers of hanoi code
Created October 6, 2014 13:51
Towers of Hanoi solution in ruby
require 'minitest/spec'
require 'minitest/autorun'
describe 'Game' do
it 'should have 3 pegs' do
game = Game.new
game.pegs.count.must_equal 3
end
it 'should have 3 discs by default' do
I'm trying to test the controller - to make sure that a logged in user who is not an admin user, cannot look at another users show page, and that they can look at their own.
I'm beginning to suspect that this testing is really only relevant inside the policy tests and that I have to assume that the controllers are following the policies as described.
The system uses:
Rails 4.2.1
Minitest
Devise
Pundit
Rolify
@aamax
aamax / gist:0556b89c1537b45354d4
Created July 14, 2015 17:09
how to do JSON return in this format?
I have a model that looks like:
# == Schema Information
#
# Table name: vendors
#
# id :integer not null, primary key
# company_name :string
# category :string
#