Skip to content

Instantly share code, notes, and snippets.

@lightcap
lightcap / deploy.rb
Created February 21, 2009 01:50 — forked from defunkt/deploy.rb
# deploy to staging from your current topic branch, with ease
set :branch, "origin/#{`git branch`.scan(/^\* (\S+)/)}"
chinook: mattkern$ git reset --hard HEAD
HEAD is now at 65d77f3 ...and back to regularly scheduled programming.
# Examples of Nesting Associated Attributes
# This is a look at the various ways to set associated attributes through
# nested parameters. For example, let's say Project has_many :tasks and
# we want to update the tasks the same time we edit a project. There are
# several ways this interface could be handled, and here are a few.
#
# For these examples, we're trying to create two new tasks and update an
# existing task (with id 3) through a project.
# Approach 1
## markup
<div>
<ul>
<li>
<div class="image">
<img src="/system/events/icons/1/small_IMG_1651.jpg" />
</div>
<div>
<span class="ttl">THIS IS A TITLE</span>
This is the text...
<%= javascript_tag "var auth_token = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
results in:
//<![CDATA[
var auth_token = "ZOqYXojCWdc5FZlFY11sHtDW4dnC9eh2/G2M7PcDEDY=";
//]]>
</script>
When called like:
<datacom xmlns="http://www.pvpowered.com">
<inverter>
<inverter_model>286</inverter_model>
<inverter_serial>02860910090016</inverter_serial>
<text_serial>PV2600BBAF0910090016</text_serial>
<firmware_version>3.18</firmware_version>
<micro_rev>5</micro_rev>
<pvm_status>00</pvm_status>
<modbus_addr>81</modbus_addr>
<power_board_serial>0</power_board_serial>
class MonitorPoll < ActiveRecord::Base
set_table_name :inverter_monitor_polls
belongs_to :inverter
has_one :inverter, :foreign_key => :last_poll_id
end
class Inverter < ActiveRecord::Base
## monitor_poll_test.rb
require 'test_helper'
class MonitorPollTest < ActiveSupport::TestCase
should_belong_to :inverter
should_belong_to :inverter_property
context "An instance of MonitorPoll" do
setup do
class ActiveSupport::TestCase
def setup_fault
@inverter_model = Factory(:inverter_model)
@inverter = Factory(:inverter, :inverter_model => @inverter_model)
@fault_message = Factory(:fault_message, :inverter => @inverter)
@inverter_property = Factory(:inverter_property, :inverter => @inverter)
@inverter_state = Factory(:inverter_state)
@old_inverter_state = Factory(:old_inverter_state)
@device = Factory(:device)
@fault_group = Factory(:fault_group, :device => @device)
pvpower@ey06-s00033 /data/gar/current $ RAILS_ENV=staging script/console
Loading staging environment (Rails 2.0.2)
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:263:in `load_missing_constant':NameError: uninitialized constant Paperclip::CallbackCompatability
/usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- html/document (MissingSourceFile)
from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from /usr/lib64/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/assertions/response_assertions.rb:2
from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_requir