Skip to content

Commit

Permalink
build models using rails scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
dereke committed Oct 2, 2019
1 parent 205efc3 commit d83fe1e
Show file tree
Hide file tree
Showing 109 changed files with 1,789 additions and 71 deletions.
9 changes: 9 additions & 0 deletions .exrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let g:vigun_extra_keywords = ['test']

let g:vigun_commands = [
\ {
\ 'pattern': 'test/.*_test.rb$',
\ 'normal': 'rails test',
\ 'debug': 'BACKTRACE=1 rails test',
\ }
\]
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AllCops:
- "db/schema.rb"
- "node_modules/**/*"
- "vendor/**/*"
- "bin/bundle"

Documentation:
Enabled: false
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ gem 'komponent', '>= 3.0.0.beta1'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'awesome_print'
gem 'byebug', platforms: %i[mri mingw x64_mingw]
gem 'rails_best_practices'
gem 'rubocop-performance'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ GEM
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
awesome_print (1.8.0)
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.5)
Expand Down Expand Up @@ -241,6 +242,7 @@ PLATFORMS
ruby

DEPENDENCIES
awesome_print
bootsnap (>= 1.4.2)
byebug
capybara (>= 2.15)
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/group_types.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
4 changes: 4 additions & 0 deletions app/assets/stylesheets/group_websites.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
4 changes: 4 additions & 0 deletions app/assets/stylesheets/groups.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
4 changes: 4 additions & 0 deletions app/assets/stylesheets/project_statuses.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
80 changes: 80 additions & 0 deletions app/assets/stylesheets/scaffold.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
body {
background-color: #fff;
color: #333;
margin: 33px;
}

body, p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}

pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}

a {
color: #000;
}

a:visited {
color: #666;
}

a:hover {
color: #fff;
background-color: #000;
}

th {
padding-bottom: 5px;
}

td {
padding: 0 5px 7px;
}

div.field,
div.actions {
margin-bottom: 10px;
}

#notice {
color: green;
}

.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px 7px 0;
margin-bottom: 20px;
background-color: #f0f0f0;
}

#error_explanation h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px -7px 0;
background-color: #c00;
color: #fff;
}

#error_explanation ul li {
font-size: 12px;
list-style: square;
}

label {
display: block;
}
4 changes: 4 additions & 0 deletions app/assets/stylesheets/tags.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
50 changes: 50 additions & 0 deletions app/controllers/group_types_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

class GroupTypesController < ApplicationController
before_action :set_group_type, only: %i[show edit update destroy]

def index
@group_types = GroupType.all
end

def show; end

def new
@group_type = GroupType.new
end

def edit; end

def create
@group_type = GroupType.new(group_type_params)

if @group_type.save
redirect_to @group_type, notice: 'Group type was successfully created.'
else
render :new
end
end

def update
if @group_type.update(group_type_params)
redirect_to @group_type, notice: 'Group type was successfully updated.'
else
render :edit
end
end

def destroy
@group_type.destroy!
redirect_to group_types_url, notice: 'Group type was successfully destroyed.'
end

private

def set_group_type
@group_type = GroupType.find(params[:id])
end

def group_type_params
params.require(:group_type).permit(:name)
end
end
56 changes: 56 additions & 0 deletions app/controllers/group_websites_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

class GroupWebsitesController < ApplicationController
before_action :set_group_website, only: %i[show edit update destroy]

before_action :set_group

def index
@group_websites = @group.websites
end

def show; end

def new
@group_website = @group.websites.new
end

def edit; end

def create
@group_website = @group.websites.new(group_website_params)

if @group_website.save
redirect_to [@group, @group_website], notice: 'Group website was successfully created.'
else
render :new
end
end

def update
if @group_website.update(group_website_params)
redirect_to [@group, @group_website], notice: 'Group website was successfully updated.'
else
render :edit
end
end

def destroy
@group_website.destroy
redirect_to group_group_websites_url(@group), notice: 'Group website was successfully destroyed.'
end

private

def set_group
@group = current_user.groups.find(params['group_id'])
end

def set_group_website
@group_website = GroupWebsite.find(params[:id])
end

def group_website_params
params.require(:group_website).permit(:website, :group_id)
end
end
59 changes: 59 additions & 0 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

class GroupsController < ApplicationController
before_action :set_group, only: %i[show edit update destroy]

def index
@groups = Group.all
end

def show; end

def new
@group = Group.new
end

def edit; end

def create
@group = current_user.groups.new(group_params)

if @group.save
redirect_to @group, notice: 'Group was successfully created.'
else
render :new
end
end

def update
if @group.update(group_params)
redirect_to @group, notice: 'Group was successfully updated.'
else
render :edit
end
end

def destroy
@group.destroy
redirect_to groups_url, notice: 'Group was successfully destroyed.'
end

private

def set_group
@group = Group.find(params[:id])
end

def group_params
params.require(:group).permit(
:name,
:abbreviation,
:opening_hours,
:contact_name,
:contact_email,
:contact_phone,
:gdpr,
:gdpr_email_verified
)
end
end
50 changes: 50 additions & 0 deletions app/controllers/initiative_statuses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

class InitiativeStatusesController < ApplicationController
before_action :set_initiative_status, only: %i[show edit update destroy]

def index
@initiative_statuses = InitiativeStatus.all
end

def show; end

def new
@initiative_status = InitiativeStatus.new
end

def edit; end

def create
@initiative_status = InitiativeStatus.new(initiative_status_params)

if @initiative_status.save
redirect_to @initiative_status, notice: 'Initiative status was successfully created.'
else
render :new
end
end

def update
if @initiative_status.update(initiative_status_params)
redirect_to @initiative_status, notice: 'Initiative status was successfully updated.'
else
render :edit
end
end

def destroy
@initiative_status.destroy
redirect_to initiative_statuses_url, notice: 'Initiative status was successfully destroyed.'
end

private

def set_initiative_status
@initiative_status = InitiativeStatus.find(params[:id])
end

def initiative_status_params
params.require(:initiative_status).permit(:name, :description)
end
end
Loading

0 comments on commit d83fe1e

Please sign in to comment.