diff --git a/app/assets/stylesheets/reminders.scss b/app/assets/stylesheets/reminders.scss new file mode 100644 index 0000000..2ecfee2 --- /dev/null +++ b/app/assets/stylesheets/reminders.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Reminders controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: https://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss new file mode 100644 index 0000000..bb2597f --- /dev/null +++ b/app/assets/stylesheets/scaffolds.scss @@ -0,0 +1,65 @@ +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; } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 09705d1..6b4dcfa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,2 +1,3 @@ class ApplicationController < ActionController::Base + before_action :authenticate_user! end diff --git a/app/controllers/reminders_controller.rb b/app/controllers/reminders_controller.rb new file mode 100644 index 0000000..4aa60e5 --- /dev/null +++ b/app/controllers/reminders_controller.rb @@ -0,0 +1,51 @@ +class RemindersController < ApplicationController + before_action :set_reminder, only: %i[show edit update destroy] + + def index + @reminders = Reminder.all + end + + def show; end + + def new + @reminder = Reminder.new + end + + def edit; end + + def create + @reminder = Reminder.new(reminder_params) + @reminder.user_id = current_user.id + + if @reminder.save + redirect_to @reminder, notice: 'Reminder was successfully created.' + else + render :new + end + end + + def update + if @reminder.update(reminder_params) + redirect_to @reminder, notice: 'Reminder was successfully updated.' + else + render :edit + end + end + + def destroy + @reminder.destroy + redirect_to reminders_url, notice: 'Reminder was successfully destroyed.' + end + + private + + # Use callbacks to share common setup or constraints between actions. + def set_reminder + @reminder = Reminder.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def reminder_params + params.require(:reminder).permit(:title, :body, :date, :user_id) + end +end diff --git a/app/helpers/reminders_helper.rb b/app/helpers/reminders_helper.rb new file mode 100644 index 0000000..1d8669d --- /dev/null +++ b/app/helpers/reminders_helper.rb @@ -0,0 +1,2 @@ +module RemindersHelper +end diff --git a/app/models/reminder.rb b/app/models/reminder.rb new file mode 100644 index 0000000..108395d --- /dev/null +++ b/app/models/reminder.rb @@ -0,0 +1,7 @@ +class Reminder < ApplicationRecord + belongs_to :user + + validates :title, presence: true + validates :body, presence: true + validates :date, presence: true +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 06db79b..cd695e2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,5 +11,10 @@
<%= yield %> + +<%= link_to('Logout', destroy_user_session_path) %>
+ <% end %>