This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the 2nd project's project_item | |
(rdb:5) p self.project.project_items[1] | |
#<ProjectItem id: 8, project_id: 2, product_id: 67, quantity: 1, unit_price: #<BigDecimal:10bde4cc8,'0.25E2',9(18)>, postal_code_of_manufacture: "29729", params: nil, postal_code_of_fabrication: nil> | |
# Find out how many possible manufacturing locations there are for this project_item | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_m').size | |
7 | |
# Get all the possible manufacturing locations for this project_item | |
(rdb:5) p self.project.project_items[1].product.product_features_for_type('l_m') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get all lookup_keys for a product | |
?> project2.project_items[1].product.product_features.map {|pf| [pf.product_feature_type.lookup_key, pf.product_feature_type.description] } | |
# pretty print | |
?> project2.project_items[1].product.product_features.map {|pf| puts [pf.product_feature_type.lookup_key, pf.product_feature_type.description].inspect } | |
# Longhand lookup_key for a product |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From console: | |
?> project | |
=> #<Project id: 1, user_id: 1, publisher_id: 2, name: "Travis_test_1", street_address: "407 Greenwood Drive", suite: "", city: "Athens", state: "GA", postal_code: "49508", country: "United States", confidential: false, owner_occupied: false, gross_square_feet: 5000, total_budget: #<BigDecimal:10b745c50,'0.5E5',9(18)>, project_type_id: nil, owner_type_id: nil, occupant_type_id: nil, project_scope_id: nil, project_phase_id: nil, session_id: nil, created_at: "2012-02-28 16:06:46", updated_at: "2012-02-29 13:41:41", saved: true, auto_project_source: true> | |
>> project.name | |
=> "Travis_test_1" | |
>> project.project_items | |
=> [#<ProjectItem id: 1, project_id: 1, product_id: 29, quantity: 1, unit_price: #<BigDecimal:10b71cff8,'0.75E2',9(18)>, postal_code_of_manufacture: "53551", params: nil, postal_code_of_fabrication: nil>, #<ProjectItem id: 2, project_id: 1, product_id: 16, quantity: 1, unit_price: #<BigDecimal:10b7164a0,'0.1E3',9(18)>, postal_code_of_manufacture: "49456", params: nil, postal_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Individual < ActiveRecord::Base | |
#attr_writer :train | |
#attr_accessor :trained | |
#attr_accessible :trained | |
#attr_protected :trained | |
before_update :untrain | |
validates :height, :presence => true, :numericality => true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IndividualsController < ApplicationController | |
def update | |
@individual = Individual.find(params[:id]) | |
# When I tried to implement this as a callback I kept getting 'SystemStackError (stack level too deep)' | |
#@individual.untrain | |
if @individual.update_attributes(params[:individual]) | |
flash[:success] = "Individual was updated" | |
redirect_to individuals_url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IndividualsController < ApplicationController | |
def update | |
@individual = Individual.find(params[:id]) | |
# When I tried to implement this as a callback I kept getting 'SystemStackError (stack level too deep)' | |
#@individual.untrain | |
if @individual.update_attributes(params[:individual]) | |
flash[:success] = "Individual was updated" | |
redirect_to individuals_url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
attributes = [ :weight, :height, :foot_size ] | |
training_data = {} | |
Individual::GENDERS.each do |gender| | |
data = [] | |
attributes.each do |attr| | |
if gender == Individual::MALE | |
data << Individual.get_gender(gender).map(&attr) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When user clicks 'submit' button loop through all selects with a 'datetime' class. | |
// Find the select element that furtherest DOWN the DOM. | |
// Add a warning to any other select elememnt that has an empty value that | |
// is further UP the DOM | |
$(".commit").click( function(e){ | |
// Html warning to append. Create a unique class name ('javascript_warning') | |
// to faciliate identifying and removing ONLY the warnings thata are added with this function. | |
// NOTE: We are piggy-backing on the existing css for the errors by using the 'inline-errors' class. | |
var warning_html = '<p class="inline-errors javascript_warning"> Warning, this is blank </p>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$(".commit").click( function(e){ | |
// To make this work we need to add the the following html to the page. | |
//<div id="dialog" title="Verify Form jQuery UI Style"> | |
//<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 0 0;"></span> You entered your e-mail address as:</p> | |
//<p id="dialog-email"></p> | |
//<p>If this is correct, click Submit Form.</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".commit").click( function(e){ | |
var warning = '<p class="inline-errors"> Warning, this is blank </p>' | |
var all_selections = []; | |
var not_filled_out = []; | |
$( '.check_value' ).children().each( function(){ | |
var li = $(this); | |
var li_value = li.val(); |