Permalink
Browse files

Add training box

  • Loading branch information...
vicramon committed Aug 25, 2014
1 parent 92d7744 commit 2631f31b3c5a416b2cc25136aa001e1ff4b23f6e
@@ -158,3 +158,30 @@ article#social_buttons
.comment_info
margin: 0 0 15px 0
#training
background: #FCDEC9
padding: 6px 20px 8px
margin: 0 0 15px 0
line-height: 2.5
font-size: 14px
input[type=text]
font-size: 13px
color: #222
font-family: Roboto
margin-right: 8px
label
font-size: 13px
margin-right: 2px
input[type=submit]
border: none
background: #FFA600
padding: 4px 12px 6px
font-size: 12px
cursor: pointer
font-family: Roboto
&:hover
// background: #E28838
opacity: .7
.error
color: red
@@ -3,4 +3,8 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
expose(:language) { cookies[:language] }
decent_configuration do
strategy DecentExposure::StrongParametersStrategy
end
end
@@ -3,19 +3,5 @@ class ChaptersController < ApplicationController
expose(:next_chapter) { chapter.next }
expose(:previous) { chapter.previous }
expose(:text) { chapter.text }
=begin
- router
- route, controller, view, template
Chapter 4: Planning the Application
Chapter 5: Modeling Data
Chapter 6: Sign In
- best way to do this?
Chapter 7: Listing
Chapter 8: Creating New
- validations
Chapter 9: Editing
Chapter 10: Deleting
=end
expose(:contact)
end
@@ -0,0 +1,20 @@
class ContactsController < ApplicationController
expose(:contact, attributes: :contact_params)
def create
if contact.save
flash[:notice] = true
session[:hide_training] = true
else
flash[:error] = true
end
redirect_to :back
end
private
def contact_params
params.require(:contact).permit(:email, :location)
end
end
@@ -1,4 +1,5 @@
class HomeController < ApplicationController
expose(:contact)
def all
@chapters = Chapter.all_chapters
View
@@ -0,0 +1,3 @@
class Contact < ActiveRecord::Base
validates :email, presence: true
end
@@ -0,0 +1,16 @@
- if flash[:notice]
#training
Thanks for your interest! I'll be sure to let you know if I host a training near you.
- unless session[:hide_training]
#training
- if flash[:error]
.error Please enter your email address.
= form_for contact do |f|
Interested in Ember training? I'll arrange a session if I get enough people.
%br
= f.label :email, "Email:"
= f.text_field :email
= f.label :location, "Preferred Location (optional):"
= f.text_field :location
= f.submit "Submit"
@@ -1,6 +1,6 @@
%section#chapter
= render 'chapter_nav'
= render 'training'
%article#markdown
~ markdown text
@@ -1,4 +1,5 @@
%section#chapter
= render 'chapters/training'
- @chapters.each do |chapter|
%article#markdown
~ markdown chapter.text
View
@@ -5,5 +5,7 @@
get 'chapters/all', to: 'home#all'
get 'about', to: 'home#about'
get 'contact', to: 'home#contact'
resources :contacts, only: [:create]
get '*path', to: 'chapters#show', as: 'chapter'
end
@@ -0,0 +1,9 @@
class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.string :email
t.string :location
t.boolean :live
end
end
end
View
@@ -11,9 +11,15 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 0) do
ActiveRecord::Schema.define(version: 20140825000109) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "contacts", force: true do |t|
t.string "email"
t.string "location"
t.boolean "live"
end
end

0 comments on commit 2631f31

Please sign in to comment.