Skip to content

Commit ea9120b

Browse files
committed
add controller Pin & views, routes
1 parent f3df24b commit ea9120b

File tree

13 files changed

+90
-53
lines changed

13 files changed

+90
-53
lines changed

app/assets/javascripts/pins.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/stylesheets/pins.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the Pins controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/

app/controllers/pins_controller.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class PinsController < ApplicationController
2+
def index
3+
4+
end
5+
def new
6+
@pin = Pin.new
7+
end
8+
def create
9+
@pin = Pin.new(pin_params)
10+
end
11+
12+
private
13+
def pin_params
14+
params.require(:pin).permit(:title, :description)
15+
end
16+
end

app/helpers/pins_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module PinsHelper
2+
end

app/models/pin.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Pin < ActiveRecord::Base
2+
end

app/views/pins/index.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
%h1 The index Placeholder

app/views/pins/new.html.haml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%h1 New Form
2+
3+
= render "form"
4+
5+
= link_to "Back", root_path

config/routes.rb

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,5 @@
11
Rails.application.routes.draw do
2-
# The priority is based upon order of creation: first created -> highest priority.
3-
# See how all your routes lay out with "rake routes".
2+
resources :pins
43

5-
# You can have the root of your site routed with "root"
6-
# root 'welcome#index'
7-
8-
# Example of regular route:
9-
# get 'products/:id' => 'catalog#view'
10-
11-
# Example of named route that can be invoked with purchase_url(id: product.id)
12-
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13-
14-
# Example resource route (maps HTTP verbs to controller actions automatically):
15-
# resources :products
16-
17-
# Example resource route with options:
18-
# resources :products do
19-
# member do
20-
# get 'short'
21-
# post 'toggle'
22-
# end
23-
#
24-
# collection do
25-
# get 'sold'
26-
# end
27-
# end
28-
29-
# Example resource route with sub-resources:
30-
# resources :products do
31-
# resources :comments, :sales
32-
# resource :seller
33-
# end
34-
35-
# Example resource route with more complex sub-resources:
36-
# resources :products do
37-
# resources :comments
38-
# resources :sales do
39-
# get 'recent', on: :collection
40-
# end
41-
# end
42-
43-
# Example resource route with concerns:
44-
# concern :toggleable do
45-
# post 'toggle'
46-
# end
47-
# resources :posts, concerns: :toggleable
48-
# resources :photos, concerns: :toggleable
49-
50-
# Example resource route within a namespace:
51-
# namespace :admin do
52-
# # Directs /admin/products/* to Admin::ProductsController
53-
# # (app/controllers/admin/products_controller.rb)
54-
# resources :products
55-
# end
4+
root "pins#index"
565
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class CreatePins < ActiveRecord::Migration
2+
def change
3+
create_table :pins do |t|
4+
t.string :title
5+
t.text :description
6+
7+
t.timestamps null: false
8+
end
9+
end
10+
end

db/schema.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# encoding: UTF-8
2+
# This file is auto-generated from the current state of the database. Instead
3+
# of editing this file, please use the migrations feature of Active Record to
4+
# incrementally modify your database, and then regenerate this schema definition.
5+
#
6+
# Note that this schema.rb definition is the authoritative source for your
7+
# database schema. If you need to create the application database on another
8+
# system, you should be using db:schema:load, not running all the migrations
9+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
10+
# you'll amass, the slower it'll run and the greater likelihood for issues).
11+
#
12+
# It's strongly recommended that you check this file into your version control system.
13+
14+
ActiveRecord::Schema.define(version: 20160323225543) do
15+
16+
create_table "pins", force: :cascade do |t|
17+
t.string "title"
18+
t.text "description"
19+
t.datetime "created_at", null: false
20+
t.datetime "updated_at", null: false
21+
end
22+
23+
end

0 commit comments

Comments
 (0)