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
!!! | |
%html | |
%head | |
%title= title | |
= stylesheet_link_tag 'application', :media => 'all' | |
= stylesheet_link_tag '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css' | |
= stylesheet_link_tag '//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css' | |
= javascript_include_tag 'application' | |
/[if lte IE 8] | |
<script src="excanvas.compiled.js"></script> |
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
# You will need to install nokogiri and rubyzip gems | |
# | |
# gem install nokogiri | |
# gem install rubyzip | |
require 'nokogiri' | |
require 'open-uri' | |
require 'zip/zip' | |
IMAGES_URL = 'http://files.tinystudios.com/defaults/images/' |
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
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| | |
html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe | |
# add nokogiri gem to Gemfile | |
elements = Nokogiri::HTML::DocumentFragment.parse(html_tag).css "label, input" | |
elements.each do |e| | |
if e.node_name.eql? 'label' | |
html = %(<div class="clearfix error">#{e}</div>).html_safe | |
elsif e.node_name.eql? 'input' | |
if instance.error_message.kind_of?(Array) | |
html = %(<div class="clearfix error">#{html_tag}<span class="help-inline"> #{instance.error_message.join(',')}</span></div>).html_safe |
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
def destroy | |
Part.find(params[:id]).destroy | |
flash[:success] = "Part removed." | |
respond_to do |format| | |
format.html { redirect_to root_url } | |
format.js { redirect_to root_url } | |
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
$ rails console | |
#Loading development environment (Rails 3.1.0.rc4) | |
> a = Time.now # => 2011-07-26 01:37:59 -0500 | |
> b = Time.parse(a.to_s) # => 2011-07-26 01:37:59 -0500 | |
> a == b # => false | |
> c = a - b # => 0.653716 |
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
"a1 a2 a1".reverse.sub("a1".reverse, "a3".reverse).reverse |
NewerOlder