This file contains 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
describe Machines, "#update" do | |
before(:each) do | |
Machine.auto_migrate! | |
Machinemodel.auto_migrate! | |
@machine = Machine.create(:serial_number => "FAKENUM", :machinemodel => Machinemodel.create(:name => "IR2880")) | |
@machine.save # machine#1 | |
@machine = Machine.create(:serial_number => "FAKENUM2", :machinemodel => Machinemodel.create(:name => "IR2200")) | |
@machine.save # machine#2 | |
This file contains 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
/* AutoSaveResourceProxy */ | |
/* | |
forms must look like that: | |
<form id="quote_option_2_form" action="/quotes/1/quote_options/2" method="post"> | |
<input type="hidden" name="_method" value="put"/> | |
</form> | |
it even works with a normal div element - conventions are like so: | |
<div id="quote_option_2"> |
This file contains 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
/* original element */ | |
#users {border:0; width: 300px; height: 200px;} | |
/* needed for the plugin */ | |
.clear {clear: both;} | |
.multiselect ul.selected { background: #f1f1f1; margin: 0; padding: 0; padding-top: 1px; overflow: auto; list-style: none; border: 0; float:left; position: relative; } | |
.multiselect ul.selected li { border-bottom: #ccc 1px solid; line-height: 20px; font-size: 11px; width: 90%; } | |
.multiselect ul.selected li:hover { background: #dfdfdf;} |
This file contains 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
# namestorming | |
# SteadyStateMachine | |
# Workflowable | |
# WorkflowEngine | |
module DataMapper | |
module Is | |
module PersistentStateMachine | |
This file contains 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
state = State.get(1) | |
state.state_transitions << StateTransition.new(:target => QuoteState.get(3), :state_event => QuoteStateEvent.get(3)) | |
state.save |
This file contains 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
rescue MethodNotAllowed | |
self.status = MethodNotAllowed.status | |
{ | |
:errors => "your error message" | |
}.to_json | |
end |
This file contains 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
# quotes visible to a user | |
def quotes(query_hsh) | |
return [] if division_id.nil? || facility_id.nil? | |
if authorized?('all_quotes') | |
Quote.all(query_hsh) | |
elsif authorized?('own_quotes') | |
Quote.all({:user_id => id}.merge(query_hsh)) | |
end | |
end |
This file contains 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 Freebase | |
include HTTParty | |
format :json | |
base_uri 'http://www.freebase.com/api' | |
def self.read(q) | |
return get('/service/mqlread?', :query => {:query => '{"query":' + q + '}'})['result'] | |
end | |
end |
This file contains 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
require 'rubygems' | |
require 'ken' | |
# authentication is not needed for read-only access | |
Ken::Session.new('http://www.freebase.com', 'ma', 'xxxxx') | |
# fetch a resource | |
resource = Ken.get('/en/new_order') # => <Resource id="/en/new_order" name="New Order"> | |
# let's inspect that resource |
This file contains 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
resource.attributes.each do |attribute| | |
puts attribute.property.name | |
puts "--------------------------------" | |
# there are 4 possible variants | |
####################################### | |
# non-unique value type | |
# non-unique object type | |
# unique value type | |
# unique object type |
OlderNewer