Setup basic workout index action
This commit is contained in:
parent
de37e811f9
commit
cab5cc436e
12 changed files with 84 additions and 54 deletions
3
app/assets/javascripts/workouts.js.coffee
Normal file
3
app/assets/javascripts/workouts.js.coffee
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
3
app/assets/stylesheets/workouts.css.scss
Normal file
3
app/assets/stylesheets/workouts.css.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the workouts controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
5
app/controllers/workouts_controller.rb
Normal file
5
app/controllers/workouts_controller.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class WorkoutsController < ApplicationController
|
||||
def index
|
||||
@workouts = Workout.all
|
||||
end
|
||||
end
|
2
app/helpers/workouts_helper.rb
Normal file
2
app/helpers/workouts_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module WorkoutsHelper
|
||||
end
|
2
app/models/workout.rb
Normal file
2
app/models/workout.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
class Workout < ActiveRecord::Base
|
||||
end
|
5
app/views/workouts/index.html.erb
Normal file
5
app/views/workouts/index.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<ul>
|
||||
<% @workouts.each do |workout| %>
|
||||
<li><%= workout.date %></li>
|
||||
<% end %>
|
||||
</ul>
|
|
@ -1,56 +1,4 @@
|
|||
Allpro::Application.routes.draw do
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
# You can have the root of your site routed with "root"
|
||||
# root 'welcome#index'
|
||||
|
||||
# Example of regular route:
|
||||
# get 'products/:id' => 'catalog#view'
|
||||
|
||||
# Example of named route that can be invoked with purchase_url(id: product.id)
|
||||
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
||||
|
||||
# Example resource route (maps HTTP verbs to controller actions automatically):
|
||||
# resources :products
|
||||
|
||||
# Example resource route with options:
|
||||
# resources :products do
|
||||
# member do
|
||||
# get 'short'
|
||||
# post 'toggle'
|
||||
# end
|
||||
#
|
||||
# collection do
|
||||
# get 'sold'
|
||||
# end
|
||||
# end
|
||||
|
||||
# Example resource route with sub-resources:
|
||||
# resources :products do
|
||||
# resources :comments, :sales
|
||||
# resource :seller
|
||||
# end
|
||||
|
||||
# Example resource route with more complex sub-resources:
|
||||
# resources :products do
|
||||
# resources :comments
|
||||
# resources :sales do
|
||||
# get 'recent', on: :collection
|
||||
# end
|
||||
# end
|
||||
|
||||
# Example resource route with concerns:
|
||||
# concern :toggleable do
|
||||
# post 'toggle'
|
||||
# end
|
||||
# resources :posts, concerns: :toggleable
|
||||
# resources :photos, concerns: :toggleable
|
||||
|
||||
# Example resource route within a namespace:
|
||||
# namespace :admin do
|
||||
# # Directs /admin/products/* to Admin::ProductsController
|
||||
# # (app/controllers/admin/products_controller.rb)
|
||||
# resources :products
|
||||
# end
|
||||
root :to => 'workouts#index'
|
||||
resources :workouts
|
||||
end
|
||||
|
|
9
db/migrate/20130805003121_create_workouts.rb
Normal file
9
db/migrate/20130805003121_create_workouts.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class CreateWorkouts < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :workouts do |t|
|
||||
t.datetime :date
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
22
db/schema.rb
Normal file
22
db/schema.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# encoding: UTF-8
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20130805003121) do
|
||||
|
||||
create_table "workouts", force: true do |t|
|
||||
t.datetime "date"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
end
|
5
spec/controllers/workouts_controller_spec.rb
Normal file
5
spec/controllers/workouts_controller_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe WorkoutsController do
|
||||
|
||||
end
|
7
spec/factories/workouts.rb
Normal file
7
spec/factories/workouts.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :workout do
|
||||
date "2013-08-04 20:31:21"
|
||||
end
|
||||
end
|
19
spec/features/workouts_spec.rb
Normal file
19
spec/features/workouts_spec.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "Workouts" do
|
||||
before :all do
|
||||
@workout = FactoryGirl.create(:workout)
|
||||
end
|
||||
|
||||
describe "GET /workouts" do
|
||||
it "should return 200" do
|
||||
visit workouts_path
|
||||
page.status_code.should be 200
|
||||
end
|
||||
|
||||
it "should return workouts" do
|
||||
visit workouts_path
|
||||
page.should have_content @workout.date
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue