Skip to content

Instantly share code, notes, and snippets.

View imajes's full-sized avatar

James Cox imajes

View GitHub Profile
def mark_as(state, item)
begin
sm.state = :state.to_s
sm.save!
rescue
@logger.warn "Invalid State change attempt for #{item.class.to_s}"
end
sm.reload
sm
end
(rdb:1) asset.css("AssetId")
[#<Nokogiri::XML::Element:0x819221e8 name="AssetId" children=[#<Nokogiri::XML::Text:0x81921f68 "1038">]>]
## note how this returns an array
(rdb:1) asset.css("AssetId").inner_text
"1038"
## now i'm getting the inner text of the tag, or really the first child node. i'm behaving as if this
## is a single item but really i'm doing the op on array, so i suppose it does a map + join to make
% cat vendor/plugins/shoulda/.git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:imajes/shoulda.git
begin
hlda.action = asset.at_css("MetadataType").inner_text
hlda.format = asset.at_css("Format").inner_text
hlda.page_count = asset.at_css("PageCount").inner_text
hlda.title = asset.at_css("Title").inner_text
hlda.song_number = asset.at_css("SongNumber").inner_text
hlda.retail_price = asset.at_css("RetailPrice").inner_text.to_f
hlda.asset_type = asset.at_css("AssetType").inner_text
hlda.voicing = asset.at_css("Voicing").inner_text
hlda.performance_time = asset.at_css("PerformanceTime").inner_text.to_i
$(document).ready(function() {
$('.search').live('change', function() {
var txt = $(this).text();
$.getJSON('/sheet_musics/search/' + txt),
function(data) {
$('#result').html(data.result);
}
);
return false;
});
$(document).ready(function() {
$('.async').live('click', function() {
var current = $(this).text();
if ( current == 'show' ) {
$(this).text('hide');
} else if (current == 'hide') {
$(this).text('show');
}
$.getJSON($(this).attr('href'),
# taken from @jsmestad's gist - http://gist.github.com/406963
require 'pp'
# Make gems available
require 'rubygems'
# Dr Nic's gem inspired by
# http://redhanded.hobix.com/inspect/stickItInYourIrbrcMethodfinder.html
require 'what_methods'
require 'ap'
if ENV['RAILS_ENV'] == 'development' || ENV['RAILS_ENV'] == 'testing'
gem 'rails', :path => "vendor/rails"
else
# Bundle gem Rails instead:
gem 'rails', "= 3.0.0.rc"
end
- @item.article_pages.each do |article_page|
= f.fields_for :article_pages, article_page do |ap|
= render :partial => @item.article_pages, :locals => { :ap => ap, :template => false, :count => @item.article_pages.size }
= f.fields_for :article_pages, @article_page do |ap|
/= render :partial => '/article_pages/article_page', :object => @article_page, :locals => { :ap => ap, :template => true, :count => @item.article_pages }
- people_size = @sheet_music.contributors.size - 1 # zero based array
- @sheet_music.contributors.each_with_index do |c, idx|
- if idx == people_size
= "&amp; #{link_to c, '#'}"
- elsif idx == people_size -1
= link_to c, '#'
- else
= "#{link_to c, '#'}, "