Skip to content

Instantly share code, notes, and snippets.

View marklocklear's full-sized avatar

J. Mark Locklear marklocklear

View GitHub Profile
<h2>Sign up</h2>
<% resource.organization ||= Organization.new %>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<%= f.fields_for :organization do |organization_form| %>
<div><%= organization_form.label :name %><br />
<%= organization_form.text_field :name %></div>
#User model
class User < ActiveRecord::Base
belongs_to :organization
accepts_nested_attributes_for :organization
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
<%= form_for @rubric do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :competency %><br />
<%= f.text_field :competency, :size => 50 %>
</p>
Loading development environment (Rails 3.0.5)
ruby-1.9.2-head :001 > r = Rubric.first
=> #<Rubric id: 1, name: "Computer Technology", section_id: 2, created_at: "2011-10-18 13:53:24", updated_at: "2011-11-23 19:33:24", competency: "">
ruby-1.9.2-head :002 > r.indicators
=> [#<Indicator id: 1, rubric_id: 1, name: "Present info professionally", created_at: "2011-10-18 13:53:24", updated_at: "2011-10-18 13:53:24">, #<Indicator id: 6, rubric_id: 1, name: "test2", created_at: "2011-11-23 19:33:24", updated_at: "2011-11-23 19:33:24">]
ruby-1.9.2-head :003 > r.questions
=> [#<Question id: 1, indicator_id: 1, name: "Choosed the correct software", created_at: "2011-10-18 13:53:24", updated_at: "2011-10-18 13:53:24">, #<Question id: 7, indicator_id: 1, name: "test", created_at: "2011-11-23 19:33:24", updated_at: "2011-11-23 19:33:24">, #<Question id: 8, indicator_id: 6, name: "q2", created_at: "2011-11-23 19:33:24", updated_at: "2011-11-23 19:33:24">]
ruby-1.9.2-head :004 > klone = r.clone :include => {:indicator
@marklocklear
marklocklear / gist:1405319
Created November 29, 2011 16:03
Copy object attributes
ruby-1.9.2-head :001 > t = Template.first
=> #<Template id: 1, name: "Computer Tech Template", created_at: "2011-11-22 18:38:45", updated_at: "2011-11-22 18:38:45">
r = Rubric.new(t.attributes.merge(:name => t.name, :created_at => t.created_at))
=> #<Rubric id: nil, name: "Computer Tech Template", section_id: nil, created_at: "2011-11-22 18:38:45", updated_at: "2011-11-22 18:38:45", competency: nil>
@marklocklear
marklocklear / gist:1536897
Last active September 29, 2015 02:58
Ubuntu Settings
gnome-terminal --geometry=80x15
#set vim tab width in ~/.vimrc
set ts=2
set shiftwidth=2
#apt-get stuff
10.04
sudo apt-get install curl vim git-core build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev libzlib-ruby zlibc libopenssl-ruby bison libsqlite3-dev libssl-dev libxml2-dev libxslt-dev
12.04
[
['Acura'],
['AM General'],
['Aston Martin'],
['Audi'],
['Bentley'],
['BMW'],
['Chevrolet'],
['Chrysler'],
['Dodge'],
@marklocklear
marklocklear / appmobi
Created February 21, 2012 19:21
Appmobi path
http://localhost:58888/_emulator/_ide/login.html
ubuntu@domU-12-31:/var/www/myrailsapp$ bundle exec rake routes
todos GET /todos(.:format) todos#index
POST /todos(.:format) todos#create
new_todo GET /todos/new(.:format) todos#new
edit_todo GET /todos/:id/edit(.:format) todos#edit
todo GET /todos/:id(.:format) todos#show
PUT /todos/:id(.:format) todos#update
DELETE /todos/:id(.:format) todos#destroy
ubuntu@domU-C:/var/www/myrailsapp$ apache2ctl -t -D DUMP_MODULES
Started POST "/products" for 127.0.0.1 at 2012-06-26 08:56:23 -0400
Processing by ProductsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"bheB/PpRy3HIjAaye8vR/VlpxgIrGG22P5TQjMdnf8k=", "product"=>{"name"=>"A Few Good Men", "price"=>"13.95", "author"=>"Aarron Sorrkin", "rating"=>"PG", "runtime"=>"3"}, "commit"=>"Create Product"}
(0.2ms) BEGIN
SQL (119.1ms) INSERT INTO "products" ("created_at", "name", "price", "properties", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["created_at", Tue, 26 Jun 2012 12:56:23 UTC +00:00], ["name", "A Few Good Men"], ["price", 13], ["properties", {"author"=>"Aarron Sorrkin", "rating"=>"PG", "runtime"=>"3"}], ["updated_at", Tue, 26 Jun 2012 12:56:23 UTC +00:00]]
PG::Error: ERROR: Syntax error near 'a' at position 4
: INSERT INTO "products" ("created_at", "name", "price", "properties", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id"
(0.2ms) ROLLBACK
Completed 500 Internal Server Error in 125ms