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 'haml' | |
puts RUBY_ENGINE # "ruby" | |
puts RUBY_VERSION # "2.1.1" | |
puts Haml::VERSION # "4.0.5" | |
def hash1 | |
{:bread => 'white', :filling => 'peanut butter and jelly'} | |
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 | |
add_breadcrumb 'Home', root_url | |
def breadcrumbs | |
@breadcrumbs ||= [] | |
end | |
helper_method :breadcrumbs | |
def add_breadcrumb(name, url, options = {}) |
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 Ability | |
include CanCan::Ability | |
def initialize(user, *args) | |
super(*args) | |
alias_action :new, to: :write | |
alias_action :create, to: :publish | |
user ||= User.new # guest user (not logged in) | |
if user.has_role? :admin | |
can :manage, :all |
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
location ~ ^/(assets)/ { | |
gzip_static on; | |
expires 1y; | |
add_header Cache-Control public; | |
} |
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 ApplicationHelper | |
def content_helper(id) | |
content_tag(:div, yield, id: id) | |
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
<%= form_for(@user) do |f| %> | |
<% User::TYPES.each do |type| %> | |
<%= f.radio_button :user_type, type %> | |
<% end %> | |
<%= 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
<%= form_for(@user) do |f| %> | |
<% User.types.each_key do |type| %> | |
<%= f.radio_button :type, type %> | |
<% end %> | |
<%= 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
# app/models/artist.rb | |
class Artist < User | |
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 guest_editor? | |
desks.where(name: 'Guest Editor').exists? | |
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
Rails.application.routes.draw do | |
# 1 | |
resources :notifications, only: [] do | |
resources :reactions, only: :create | |
end | |
# 2 | |
post '/notifications/:notification_id/reactions' | |
# 3 |