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
When /^I submit valid warranty claim details$/ do | |
@warranty_registration = Factory(:warranty_registration) | |
visit new_warranty_claim_path | |
fill_in 'Failure date', :with => Time.now.strftime("%m/%d/%Y") | |
fill_in 'Serial number', :with => @warranty_registration.serial_number | |
fill_in 'Customer name', :with => @warranty_registration.full_name | |
fill_in 'Customer phone', :with => @warranty_registration.phone | |
click_button "Create" | |
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 'delegate' | |
class Foo | |
attr_accessor :fname, :lname | |
def initialize(fname, lname) | |
@fname, @lname = fname, lname | |
end | |
end | |
# create a foo object |
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 User < ActiveRecord::Base | |
@@ignore_attr = ['lname'] | |
def arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) | |
attrs = super(include_primary_key, include_readonly_attributes, attribute_names) | |
attrs.delete_if {|key,value| @@ignore_attr.include?(key.name) } | |
puts attrs.inspect | |
attrs | |
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
# $HOME/.ssh/config | |
Host *compute-1.amazonaws.com | |
User ubuntu | |
StrictHostKeyChecking no | |
UserKnownHostsFile /dev/null | |
IdentityFile ~/.ssh/your-ec2-key | |
ServerAliveInterval 30 | |
ServerAliveCountMax 120 |
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
<!-- without error --> | |
<div class="clearfix"> | |
<label for="bar">Bar</label> | |
<div class="input"> | |
<input id="foo_bar" name="foo[bar]" size="30" type="text"> | |
</div> | |
</div> | |
<!-- with error --> | |
<div class="field"> |
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
<!-- without error --> | |
<div class="clearfix"> | |
<label for="bar">Bar</label> | |
<div class="input"> | |
<input id="foo_bar" name="foo[bar]" size="30" type="text"> | |
</div> | |
</div> | |
<!-- with error --> | |
<div class="clearfix error"> |
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
# ./config/environment.rb | |
ActionView::Base.field_error_proc = Proc.new {|html, instance| html } |
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
# ./app/helpers/boot_strap_form_builder.rb | |
class BootStrapFormBuilder < ActionView::Helpers::FormBuilder | |
def text_field(method, options={}) | |
t = @template | |
t.content_tag(:div, :class => "clearfix#{' error' unless @object.errors[method].blank?}") { | |
t.concat(t.label_tag method) | |
t.concat(t.content_tag(:div, :class => "input#{' error' unless @object.errors[method].blank?}") { | |
t.concat(super method) |
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
<%= form_for(@foo, :builder => BootStrapFormBuilder) do |f| %> | |
<%= f.error_explanations %> | |
<%= f.text_field :bar %> | |
<%= f.submit %> | |
<% 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
I18n.t!(:some_key) rescue nil || :some_key.to_s |