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 "rspec" | |
def nesting(string) | |
opens = 0 | |
string.each_char do |c| | |
case c | |
when "(" then opens += 1 | |
when ")" then opens > 0 ? (opens -= 1) : (return 0) | |
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
<ul id="products" class="home-products"> | |
<% @products.each do |product| %> | |
<% if Spree::Config[:show_zero_stock_products] || product.has_stock? %> | |
<%= content_tag_for :li, product do %> | |
<%= link_to product do %> | |
<div class="product-image"> | |
<%= product_image(product) %> | |
</div> | |
<%= link_to truncate(product.name, length: 50), product, class: "title" %> | |
<%= product_tooltip(product) %> |
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: Manage categories | |
In order to clasify the brand products | |
As an admin | |
I want to assign categories to a product | |
Scenario: Manage product categories | |
Given a brand with a category and a product | |
And I am an admin | |
When I add the brand category to the product |
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
<%= content_tag "div", class: "milestones", | |
data: { | |
milestones: render(template: "api/v1/milestones/index.json") | |
} do %> | |
<%= javascript_tag do %> | |
jQuery(function(){ | |
App.init(); | |
}); | |
<% 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
authenticated do | |
root :to => 'users#home' | |
end | |
root :to => 'pages#home' |
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 "commentator_templates" | |
#= require "commentator_poster" | |
#= require "commentator_params" | |
class window.Commentator | |
constructor: (args) -> | |
params = new CommentatorParams(args) | |
@el = params.el() | |
@url = params.url() |
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 ApplicationController < ActionController::Base | |
# other stuff .. | |
def notify(*args) | |
Notifications::Notifier.new.notify(*args) | |
end | |
end | |
class CommentsController < ApplicationController |
This are different examples of doing the same thing, "mark a notification as read", and the pros and cons that I see in each example
- The user clicks the notification link
- The system POSTs to the action "notifications/:id/mark_as_read"
- The controller calls the method Notification#mark_as_read
- The model updates the attribute "read" saves the Notification record
OlderNewer