Skip to content

Instantly share code, notes, and snippets.

View radar's full-sized avatar

Ryan Bigg radar

View GitHub Profile
<% Category.all.each do |category| %>
<option value="<%= category_path(category) %>"><%= category.name %></option>
<% end %>
context "create order" do
let(:current_api_user) do
user = Spree.user_class.new(:email => "[email protected]")
# other stuff goes here
end
it "can create an order" do
variant = create(:variant)
def smart_titleize(word, pattern)
words = word.split(' ')
processed_words = []
words.each do |aWord|
aWord = Regexp.escape(aWord)
aWord = aWord.capitalize unless Regexp.escape("#{pattern}").match(aWord) || /^[A-Z]*$/.match(aWord) || /^[a-z]{2,}$/.match(aWord) || /^[0-9]*$/.match(aWord)
aWord = aWord.gsub(/-([A-Za-z0-9]+)/) {|s| s.upcase}
aWord = aWord.gsub(/(AR\-15)/i) {$&.upcase}
aWord = aWord.gsub(/(TAC-)/i) {$&.upcase}
processed_words << aWord
def edit_measurements
@estimate = Estimate.find(params[:id])
@measurements = @estimate.measurements
end
def update_measurements
#Find object using form parameters
@estimate = Estimate.find(params[:id])
#Update subject
if @estimate.update_attributes(params[:estimate])
module ApplicationHelper
def full_title(page_title)
base_title = "Vende Comigo"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
<%= display_messages %>
# returns {:error=>"Email/senha incorretos."}
nesting of 20 is too deep (JSON::NestingError)
./features/support/interactors.rb:4:in `hover_over'
./features/step_definitions/shortlist_new_steps.rb:11
./features/step_definitions/shortlist_new_steps.rb:10:in `/^I click the product shortlist link in the main navigation$/'
features/public/shortlists/view_product_shortlist.feature:10:in `And I click the product shortlist link in the main navigation'
@all_authentications.marshal_dump.each do |k,v|
v.each do |auth|
node(auth.id.to_sym) {{ created_at: auth.created_at }}
end
end
@radar
radar / gist:5315139
Last active December 15, 2015 20:00 — forked from gotjosh/gist:5315106
var totalPages = 50, buttons = 3;
var currentPage = lowerLimit = upperLimit = Math.min(50, totalPages);
for (var b = 1; b < buttons && b < totalPages;) {
if (lowerLimit > 1 ) { lowerLimit--; b++; }
if (b < buttons && upperLimit < totalPages) { upperLimit++; b++; }
}