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_tag :login do %> | |
<%= label_tag :login, "Email or Username" %> | |
<%= text_field_tag :login %> | |
<%= submit_tag "Log In" %> | |
<% 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 ApplicationController < ActionController::Base | |
protect_from_forgery with: :exception | |
private | |
def signed_in? | |
!!session[:user_id] | |
end | |
helper_method :signed_in? | |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title><%= content_for?(:title) ? yield(:title) : "ApplicationName" %></title> | |
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> | |
<%= javascript_include_tag "application", "data-turbolinks-track" => true %> | |
<%= csrf_meta_tags %> | |
</head> | |
<body> |
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 @user, url: :signup do |f| %> | |
<%= f.label :email %> | |
<%= f.email_field :email %> | |
<%= f.label :password %> | |
<%= f.password_field :password, autocomplete: 'off' %> | |
<input type="checkbox" id="show_password" /> | |
<label for="show_password">Show Password</label> |
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
container = document.getElementById('items') | |
new List(container) |
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_tag @item, method: :delete do |f| %> | |
<%= label_tag :name, "Type the item's name to delete" %> | |
<%= text_field_tag :name, nil, | |
data: { name: @item.name }, autocomplete: 'off' %> | |
<%= submit_tag "Delete Item", disabled: true %> | |
<% 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 Item < ActiveRecord::Base | |
def stars | |
User.find star_ids | |
end | |
def stars_count | |
$redis.scard redis_key(:stars) | |
end | |
private |
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
module Gravatar | |
BASE_URL = "http://www.gravatar.com/avatar".freeze | |
def gravatar_url(options = {}) | |
"#{BASE_URL}/#{email_hash}?#{options.to_query}" | |
end | |
private | |
def email_hash |
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 | |
protect_from_forgery with: :exception | |
private | |
# use default_url_options ? | |
def item_path(item) | |
super(item.user, item) | |
end | |
helper_method :item_path | |
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 ItemsController < ApplicationController | |
def create | |
@item = Item.create!(item_params) | |
end | |
private | |
def item_params | |
params.require(:item).permit(:name, :public) | |
end |
OlderNewer