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
Feature: API | |
In order to use the service from third party apps | |
As a user | |
I want to be able to use an API | |
Background: | |
Given a user exists # Pickle | |
And I login as the user using basic auth | |
Scenario Outline: Get a ticket |
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 XXX < ActiveRecord::Base | |
before_validation :format_phone | |
validates_presence_of :phone | |
validates_length_of :phone, :is => 10 | |
attr_accessible :phone |
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
# inside Application controller | |
around_filter :global_request_logging | |
def global_request_logging | |
http_request_header_keys = request.headers.keys.select{|header_name| header_name.match("^HTTP.*")} | |
http_request_headers = request.headers.select{|header_name, header_value| http_request_header_keys.index(header_name)} | |
logger.info "Received #{request.method.inspect} to #{request.url.inspect} from #{request.remote_ip.inspect}. Processing with headers #{http_request_headers.inspect} and params #{params.inspect}" | |
begin | |
yield |
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
<% @merchant_campaign.instance_variable_get(:@attributes).each do |attribute, value| %> | |
<tr> | |
<td><%= attribute %></td> | |
<td><%= value %></td> | |
</tr> | |
<% 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
<% f.fields_for :member_collection do |builder| %> | |
<%= render "membrer_collection_fields", :form => builder %> | |
<% 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
def serializable_hash(options = {}) | |
my_options = {:except => [:id, :category, :draws, :owner_identifier, :owner_reference_data, | |
:primary_image, :related_data, :created_at, :updated_at, :creating_user_id ], | |
:include => []}.merge(options ||= {}) | |
s = serializable_hash(my_options) | |
s["address"] = address.serializable_hash_for_public(options) | |
s | |
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
def serializable_hash(options = {}) | |
# TODO exclude the id | |
options = {:include => [:address, :location, :hours_of_operations, :slow_periods, :discounts], | |
:except => [:created_at, :updated_at, :creating_user_id]}.merge(options ||= {}) | |
super options | |
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 JobClass | |
def perform | |
begin | |
#I do stuff here | |
rescue Exception => e | |
# catch all exceptions | |
HoptoadNotifier.notify(e) | |
ensure | |
# we want this job to just run continuously, but we don't have an 'auto' way to do that | |
# so we schedule a new one every time we run |
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
Day Job: Sr. Software Engineer at ThinkNear | |
Open Source contribution (if any): rails docs and guides | |
Tell me about your experience with Ruby/Rails: started using it in fall 2010, and have been on it full time every since. Big change from my background in Java (used to work at Amazon.com) | |
How do you use GitHub: for everything. personal and business. We keep our companies repositories on github. We also use it to collaborate with contractors. | |
Favorite luchador(es):Rikochet |
OlderNewer