This file contains hidden or 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 index | |
@items = Item.all | |
respond_to do |format| | |
format.html { @items } | |
format.json { render json: @items } | |
format.xml { render xml: @items } | |
end | |
end |
This file contains hidden or 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 | |
validates :name, presence: true | |
end |
This file contains hidden or 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
desc "Print name" | |
task :name, [:name] do |t, arguments| | |
puts "My name is #{arguments[:name]}" | |
end | |
desc "Favorite animal" | |
task :animal, [:animal] do |t, arguments| | |
puts "My favorite animal is #{arguments[:animal]}" | |
end |
This file contains hidden or 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 AccountPresenter | |
extend Forwardable | |
attr_reader :account | |
def_delegators :account, :amount, :created_at | |
def initialize(account) | |
@account = account | |
end |
This file contains hidden or 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 Seed | |
def initialize | |
generate_users | |
generate_items | |
generate_orders | |
end | |
def generate_users | |
50.times do |i| | |
user = User.create!( |
This file contains hidden or 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
development: | |
github_key: 710899dd3710a6a9814e | |
github_secret: 102dc5253ae360eaae533e7dc5ceb46929dcbe4b |
This file contains hidden or 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 cache_key_for(model) | |
prefix = model.to_s.downcase.pluralize | |
count = model.count | |
max_updated_at = model.maximum(:updated_at).try(:utc).try(:to_s, :number) | |
"#{prefix}/all-#{count}-#{max_updated_at}" | |
end | |
end |
This file contains hidden or 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
namespace :deploy do | |
desc "Deploys app to Github & production." | |
task all: :environment do | |
if system("rake test:all") == false | |
puts "The tests fail." | |
break | |
end | |
puts "The tests passed." |
This file contains hidden or 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
# Original Router | |
Rails.application.routes.draw do | |
resources :articles | |
resources :comments | |
resource :account, only: [:show] do | |
get :work | |
end | |
get '/login' => 'sessions#new' |