first raw implementation of the form
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
class PagesController < ApplicationController
|
||||
def thanks
|
||||
end
|
||||
end
|
||||
@@ -2,4 +2,20 @@ class SupportersController < ApplicationController
|
||||
def new
|
||||
@supporter = Supporter.new
|
||||
end
|
||||
|
||||
def create
|
||||
@supporter = Supporter.new supporter_form_params
|
||||
if @supporter.save
|
||||
redirect_to thanks_path
|
||||
else
|
||||
flash.now[:danger] = t 'shared.actions.failed'
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def supporter_form_params
|
||||
params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :age_category)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
module ApplicationHelper
|
||||
def title(page_title)
|
||||
content_for :title, page_title.to_s
|
||||
page_title
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
html
|
||||
head
|
||||
title Ch420
|
||||
title #CH420 - #{content_for(:title)}
|
||||
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
||||
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
||||
= csrf_meta_tags
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.lead
|
||||
h1 = title t('.title')
|
||||
@@ -0,0 +1,10 @@
|
||||
h1 = title t('.title')
|
||||
= simple_form_for @supporter do |f|
|
||||
= f.input :first_name
|
||||
= f.input :last_name
|
||||
= f.input :street
|
||||
= f.input :zip
|
||||
= f.input :email
|
||||
= f.input :support, as: :radio_buttons, collection: t('support_type'), label_method: :last, value_method: :first
|
||||
= f.input :age_category, as: :radio_buttons, collection: t('age_category'), label_method: :last, value_method: :first
|
||||
= f.submit value: t('.submit'), class: 'btn btn-success'
|
||||
@@ -1 +1,2 @@
|
||||
h1 Test
|
||||
= render 'form'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user