Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

haml haml haml haml

  • Loading branch information...
commit 81a47e26d445099d48ffb441512062bf1774776c 1 parent 5119aba
Jeffrey Chupp semanticart authored
2  Gemfile
View
@@ -1,6 +1,8 @@
source 'https://rubygems.org'
gem 'rails', '3.2.2'
+
+gem 'haml'
gem 'jquery-rails'
gem 'pg'
gem 'thin'
2  Gemfile.lock
View
@@ -46,6 +46,7 @@ GEM
multi_json (~> 1.0)
factory_girl (2.6.0)
activesupport (>= 2.3.9)
+ haml (3.1.4)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
@@ -134,6 +135,7 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 3.2.1)
factory_girl
+ haml
jquery-rails
pg
pry
2  app/assets/stylesheets/players.css.sass
View
@@ -0,0 +1,2 @@
+body
+ background: red
3  app/assets/stylesheets/players.css.scss
View
@@ -1,3 +0,0 @@
-// Place all the styles related to the players controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
3  app/assets/stylesheets/seasons.css.scss
View
@@ -1,3 +0,0 @@
-// Place all the styles related to the seasons controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
29 app/controllers/players_controller.rb
View
@@ -1,17 +1,30 @@
class PlayersController < ApplicationController
+
def index
- if params[:with_seasons]
- render json: Player.all(include: :seasons).as_json(with_seasons: true, view: :index)
- else
- render json: Player.all.as_json(view: :index)
+ respond_to do |format|
+ format.html { @players = Player.all }
+
+ format.json do
+ if params[:with_seasons]
+ render json: Player.all(include: :seasons).as_json(with_seasons: true, view: :index)
+ else
+ render json: Player.all.as_json(view: :index)
+ end
+ end
end
end
def show
- if params[:with_seasons]
- render json: Player.find_by_id(params[:id]).as_json(with_seasons: true)
- else
- render json: Player.find_by_id(params[:id]).as_json
+ respond_to do |format|
+ format.html { @player = Player.find_by_id(params[:id]) }
+
+ format.json do
+ if params[:with_seasons]
+ render json: Player.find_by_id(params[:id]).as_json(with_seasons: true)
+ else
+ render json: Player.find_by_id(params[:id]).as_json
+ end
+ end
end
end
end
2  app/views/players/index.html.erb
View
@@ -1,2 +0,0 @@
-<h1>Players#index</h1>
-<p>Find me in app/views/players/index.html.erb</p>
3  app/views/players/index.html.haml
View
@@ -0,0 +1,3 @@
+%h1 Players#index
+%p Find me in app/views/players/index.html.haml
+%p @players is #{@players.inspect}
2  app/views/players/show.html.erb
View
@@ -1,2 +0,0 @@
-<h1>Players#show</h1>
-<p>Find me in app/views/players/show.html.erb</p>
3  app/views/players/show.html.haml
View
@@ -0,0 +1,3 @@
+%h1 Players#show
+%p Find me in app/views/players/show.html.erb
+%p @player is #{@player.inspect}
59 config/routes.rb
View
@@ -1,64 +1,9 @@
BaseballHackDayPre::Application.routes.draw do
+ root :to => 'players#index'
+
resources :players, only: [:index, :show] do
resources :seasons, only: [:index, :show]
end
resources :seasons, only: [:index, :show]
-
- # The priority is based upon order of creation:
- # first created -> highest priority.
-
- # Sample of regular route:
- # match 'products/:id' => 'catalog#view'
- # Keep in mind you can assign values other than :controller and :action
-
- # Sample of named route:
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
- # This route can be invoked with purchase_url(:id => product.id)
-
- # Sample resource route (maps HTTP verbs to controller actions automatically):
- # resources :products
-
- # Sample resource route with options:
- # resources :products do
- # member do
- # get 'short'
- # post 'toggle'
- # end
- #
- # collection do
- # get 'sold'
- # end
- # end
-
- # Sample resource route with sub-resources:
- # resources :products do
- # resources :comments, :sales
- # resource :seller
- # end
-
- # Sample resource route with more complex sub-resources
- # resources :products do
- # resources :comments
- # resources :sales do
- # get 'recent', :on => :collection
- # end
- # end
-
- # Sample resource route within a namespace:
- # namespace :admin do
- # # Directs /admin/products/* to Admin::ProductsController
- # # (app/controllers/admin/products_controller.rb)
- # resources :products
- # end
-
- # You can have the root of your site routed with "root"
- # just remember to delete public/index.html.
- # root :to => 'welcome#index'
-
- # See how all your routes lay out with "rake routes"
-
- # This is a legacy wild controller route that's not recommended for RESTful applications.
- # Note: This route will make all actions in every controller accessible via GET requests.
- # match ':controller(/:action(/:id))(.:format)'
end
Please sign in to comment.
Something went wrong with that request. Please try again.