From 86916794341f20b26b9a321f1e15f9521f94a618 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sun, 17 Dec 2023 16:32:09 +0000 Subject: Tidied up the basic event index and form --- app/controllers/events_controller.rb | 4 ++-- app/views/events/_form.html.erb | 10 +++++----- app/views/events/index.html.erb | 2 ++ package.json | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 13c7cec..62708a5 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -3,7 +3,7 @@ class EventsController < ApplicationController # GET /events or /events.json def index - @events = Event.all + @events = Event.all.order(date: :asc) end # GET /events/1 or /events/1.json @@ -25,7 +25,7 @@ class EventsController < ApplicationController respond_to do |format| if @event.save - format.html { redirect_to event_url(@event), notice: "Event was successfully created." } + format.html { redirect_to events_path, notice: "Event was successfully created." } format.json { render :show, status: :created, location: @event } else format.html { render :new, status: :unprocessable_entity } diff --git a/app/views/events/_form.html.erb b/app/views/events/_form.html.erb index db05a72..da7f932 100644 --- a/app/views/events/_form.html.erb +++ b/app/views/events/_form.html.erb @@ -12,16 +12,16 @@ <% end %>
- <%= form.label :date, style: "display: block" %> - <%= form.date_field :date %> + <%= form.label :date, style: "display: block", class: "form-label" %> + <%= form.date_field :date, class: "form-control" %>
- <%= form.label :name, style: "display: block" %> - <%= form.text_field :name %> + <%= form.label :name, style: "display: block", class: "form-label" %> + <%= form.text_field :name, class: "form-control" %>
- <%= form.submit %> + <%= form.submit class: "btn btn-primary mt-2"%>
<% end %> diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 654d317..16c656b 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -2,6 +2,8 @@

Events

+<%= render partial: "events/form", locals: { event: Event.new } %> + <%= link_to "New event", new_event_path %> diff --git a/package.json b/package.json index c4f3e2e..5165739 100644 --- a/package.json +++ b/package.json @@ -24,4 +24,4 @@ "browserslist": [ "defaults" ] -} \ No newline at end of file +} -- cgit v1.2.3