Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f5c8e4
commit 4bffc71
Showing
21 changed files
with
219 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ActiveStorageValidations | ||
VERSION = '0.2' | ||
VERSION = '0.3' | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class ProjectsController < ApplicationController | ||
before_action :set_project, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /projects | ||
def index | ||
@projects = Project.all | ||
end | ||
|
||
# GET /projects/1 | ||
def show | ||
end | ||
|
||
# GET /projects/new | ||
def new | ||
@project = Project.new | ||
end | ||
|
||
# GET /projects/1/edit | ||
def edit | ||
end | ||
|
||
# POST /projects | ||
def create | ||
@project = Project.new(project_params) | ||
|
||
if @project.save | ||
redirect_to @project, notice: 'Project was successfully created.' | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
# PATCH/PUT /projects/1 | ||
def update | ||
if @project.update(project_params) | ||
redirect_to @project, notice: 'Project was successfully updated.' | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
# DELETE /projects/1 | ||
def destroy | ||
@project.destroy | ||
redirect_to projects_url, notice: 'Project was successfully destroyed.' | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_project | ||
@project = Project.find(params[:id]) | ||
end | ||
|
||
# Only allow a trusted parameter "white list" through. | ||
def project_params | ||
params.require(:project).permit! | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ProjectsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# == Schema Information | ||
# | ||
# Table name: projects | ||
# | ||
# id :integer not null, primary key | ||
# title :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Project < ApplicationRecord | ||
has_one_attached :preview | ||
has_one_attached :attachment | ||
|
||
validates :title, presence: true | ||
|
||
validates :preview, attached: true | ||
validates :attachment, attached: true, content_type: { in: 'application/pdf', message: 'is not a PDF' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<%= form_with(model: project, local: true) do |form| %> | ||
<% if project.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(project.errors.count, "error") %> prohibited this project from being saved:</h2> | ||
|
||
<ul> | ||
<% project.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :title %> | ||
<%= form.text_field :title %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :preview %> | ||
<%= form.file_field :preview %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :attachment %> | ||
<%= form.file_field :attachment %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing Project</h1> | ||
|
||
<%= render 'form', project: @project %> | ||
<%= link_to 'Show', @project %> | | ||
<%= link_to 'Back', projects_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Projects</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Title</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @projects.each do |project| %> | ||
<tr> | ||
<td><%= project.title %></td> | ||
<td><%= link_to 'Show', project %></td> | ||
<td><%= link_to 'Edit', edit_project_path(project) %></td> | ||
<td><%= link_to 'Destroy', project, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Project', new_project_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New Project</h1> | ||
|
||
<%= render 'form', project: @project %> | ||
<%= link_to 'Back', projects_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Title:</strong> | ||
<%= @project.title %> | ||
</p> | ||
|
||
<p> | ||
<strong>Preview:</strong> | ||
<%= link_to 'download', @project.preview %> | ||
</p> | ||
|
||
<p> | ||
<strong>Attachment:</strong> | ||
<%= link_to 'download', @project.attachment %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_project_path(@project) %> | | ||
<%= link_to 'Back', projects_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Rails.application.routes.draw do | ||
resources :projects | ||
resources :users | ||
root 'users#index' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class CreateProjects < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :projects do |t| | ||
t.string :title | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters