first commit
This commit is contained in:
0
app/assets/builds/.keep
Normal file
0
app/assets/builds/.keep
Normal file
2
app/assets/config/manifest.js
Normal file
2
app/assets/config/manifest.js
Normal file
@@ -0,0 +1,2 @@
|
||||
//= link_tree ../images
|
||||
//= link_tree ../builds
|
||||
0
app/assets/images/.keep
Normal file
0
app/assets/images/.keep
Normal file
2
app/assets/stylesheets/application.bootstrap.scss
Normal file
2
app/assets/stylesheets/application.bootstrap.scss
Normal file
@@ -0,0 +1,2 @@
|
||||
@import 'bootstrap/scss/bootstrap';
|
||||
@import 'bootstrap-icons/font/bootstrap-icons';
|
||||
4
app/channels/application_cable/channel.rb
Normal file
4
app/channels/application_cable/channel.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
module ApplicationCable
|
||||
class Channel < ActionCable::Channel::Base
|
||||
end
|
||||
end
|
||||
4
app/channels/application_cable/connection.rb
Normal file
4
app/channels/application_cable/connection.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
end
|
||||
end
|
||||
2
app/controllers/application_controller.rb
Normal file
2
app/controllers/application_controller.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
end
|
||||
0
app/controllers/concerns/.keep
Normal file
0
app/controllers/concerns/.keep
Normal file
70
app/controllers/suggestions_controller.rb
Normal file
70
app/controllers/suggestions_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class SuggestionsController < ApplicationController
|
||||
before_action :set_suggestion, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /suggestions or /suggestions.json
|
||||
def index
|
||||
@suggestions = Suggestion.all
|
||||
end
|
||||
|
||||
# GET /suggestions/1 or /suggestions/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /suggestions/new
|
||||
def new
|
||||
@suggestion = Suggestion.new
|
||||
end
|
||||
|
||||
# GET /suggestions/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /suggestions or /suggestions.json
|
||||
def create
|
||||
@suggestion = Suggestion.new(suggestion_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @suggestion.save
|
||||
format.html { redirect_to suggestion_url(@suggestion), notice: "Suggestion was successfully created." }
|
||||
format.json { render :show, status: :created, location: @suggestion }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @suggestion.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /suggestions/1 or /suggestions/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @suggestion.update(suggestion_params)
|
||||
format.html { redirect_to suggestion_url(@suggestion), notice: "Suggestion was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @suggestion }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @suggestion.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /suggestions/1 or /suggestions/1.json
|
||||
def destroy
|
||||
@suggestion.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to suggestions_url, notice: "Suggestion was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_suggestion
|
||||
@suggestion = Suggestion.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def suggestion_params
|
||||
params.require(:suggestion).permit(:subject, :body, :sent)
|
||||
end
|
||||
end
|
||||
2
app/helpers/application_helper.rb
Normal file
2
app/helpers/application_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ApplicationHelper
|
||||
end
|
||||
2
app/helpers/suggestions_helper.rb
Normal file
2
app/helpers/suggestions_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module SuggestionsHelper
|
||||
end
|
||||
4
app/javascript/application.js
Normal file
4
app/javascript/application.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Entry point for the build script in your package.json
|
||||
import "@hotwired/turbo-rails"
|
||||
import "./controllers"
|
||||
import * as bootstrap from "bootstrap"
|
||||
9
app/javascript/controllers/application.js
Normal file
9
app/javascript/controllers/application.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Application } from "@hotwired/stimulus"
|
||||
|
||||
const application = Application.start()
|
||||
|
||||
// Configure Stimulus development experience
|
||||
application.debug = false
|
||||
window.Stimulus = application
|
||||
|
||||
export { application }
|
||||
7
app/javascript/controllers/hello_controller.js
Normal file
7
app/javascript/controllers/hello_controller.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
this.element.textContent = "Hello World!"
|
||||
}
|
||||
}
|
||||
8
app/javascript/controllers/index.js
Normal file
8
app/javascript/controllers/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// This file is auto-generated by ./bin/rails stimulus:manifest:update
|
||||
// Run that command whenever you add a new controller or create them with
|
||||
// ./bin/rails generate stimulus controllerName
|
||||
|
||||
import { application } from "./application"
|
||||
|
||||
import HelloController from "./hello_controller"
|
||||
application.register("hello", HelloController)
|
||||
7
app/jobs/application_job.rb
Normal file
7
app/jobs/application_job.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
# Automatically retry jobs that encountered a deadlock
|
||||
# retry_on ActiveRecord::Deadlocked
|
||||
|
||||
# Most jobs are safe to ignore if the underlying records are no longer available
|
||||
# discard_on ActiveJob::DeserializationError
|
||||
end
|
||||
4
app/mailers/application_mailer.rb
Normal file
4
app/mailers/application_mailer.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: "from@example.com"
|
||||
layout "mailer"
|
||||
end
|
||||
3
app/models/application_record.rb
Normal file
3
app/models/application_record.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
primary_abstract_class
|
||||
end
|
||||
0
app/models/concerns/.keep
Normal file
0
app/models/concerns/.keep
Normal file
2
app/models/suggestion.rb
Normal file
2
app/models/suggestion.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Suggestion < ApplicationRecord
|
||||
end
|
||||
16
app/views/layouts/application.html.erb
Normal file
16
app/views/layouts/application.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Suggest</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
|
||||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
||||
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
13
app/views/layouts/mailer.html.erb
Normal file
13
app/views/layouts/mailer.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<style>
|
||||
/* Email styles need to be inline */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
||||
1
app/views/layouts/mailer.text.erb
Normal file
1
app/views/layouts/mailer.text.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= yield %>
|
||||
32
app/views/suggestions/_form.html.erb
Normal file
32
app/views/suggestions/_form.html.erb
Normal file
@@ -0,0 +1,32 @@
|
||||
<%= form_with(model: suggestion) do |form| %>
|
||||
<% if suggestion.errors.any? %>
|
||||
<div style="color: red">
|
||||
<h2><%= pluralize(suggestion.errors.count, "error") %> prohibited this suggestion from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% suggestion.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<%= form.label :subject, style: "display: block" %>
|
||||
<%= form.text_field :subject %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :body, style: "display: block" %>
|
||||
<%= form.text_area :body %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :sent, style: "display: block" %>
|
||||
<%= form.check_box :sent %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
17
app/views/suggestions/_suggestion.html.erb
Normal file
17
app/views/suggestions/_suggestion.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<div id="<%= dom_id suggestion %>">
|
||||
<p>
|
||||
<strong>Subject:</strong>
|
||||
<%= suggestion.subject %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Body:</strong>
|
||||
<%= suggestion.body %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Sent:</strong>
|
||||
<%= suggestion.sent %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
2
app/views/suggestions/_suggestion.json.jbuilder
Normal file
2
app/views/suggestions/_suggestion.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! suggestion, :id, :subject, :body, :sent, :created_at, :updated_at
|
||||
json.url suggestion_url(suggestion, format: :json)
|
||||
10
app/views/suggestions/edit.html.erb
Normal file
10
app/views/suggestions/edit.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<h1>Editing suggestion</h1>
|
||||
|
||||
<%= render "form", suggestion: @suggestion %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Show this suggestion", @suggestion %> |
|
||||
<%= link_to "Back to suggestions", suggestions_path %>
|
||||
</div>
|
||||
14
app/views/suggestions/index.html.erb
Normal file
14
app/views/suggestions/index.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<h1>Suggestions</h1>
|
||||
|
||||
<div id="suggestions">
|
||||
<% @suggestions.each do |suggestion| %>
|
||||
<%= render suggestion %>
|
||||
<p>
|
||||
<%= link_to "Show this suggestion", suggestion %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to "New suggestion", new_suggestion_path %>
|
||||
1
app/views/suggestions/index.json.jbuilder
Normal file
1
app/views/suggestions/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @suggestions, partial: "suggestions/suggestion", as: :suggestion
|
||||
9
app/views/suggestions/new.html.erb
Normal file
9
app/views/suggestions/new.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<h1>New suggestion</h1>
|
||||
|
||||
<%= render "form", suggestion: @suggestion %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Back to suggestions", suggestions_path %>
|
||||
</div>
|
||||
10
app/views/suggestions/show.html.erb
Normal file
10
app/views/suggestions/show.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<%= render @suggestion %>
|
||||
|
||||
<div>
|
||||
<%= link_to "Edit this suggestion", edit_suggestion_path(@suggestion) %> |
|
||||
<%= link_to "Back to suggestions", suggestions_path %>
|
||||
|
||||
<%= button_to "Destroy this suggestion", @suggestion, method: :delete %>
|
||||
</div>
|
||||
1
app/views/suggestions/show.json.jbuilder
Normal file
1
app/views/suggestions/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "suggestions/suggestion", suggestion: @suggestion
|
||||
Reference in New Issue
Block a user