migrate from turbolinks to turbo
This commit is contained in:
@@ -1,9 +1,52 @@
|
||||
class RpWorldsController < ApplicationController
|
||||
before_action :set_rp_world, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /rp_worlds
|
||||
def index
|
||||
@rp_worlds = RpWorld.all
|
||||
end
|
||||
|
||||
def show
|
||||
# GET /rp_worlds/1
|
||||
def show; end
|
||||
|
||||
# GET /rp_worlds/1/edit
|
||||
def edit; end
|
||||
|
||||
# POST /rp_worlds
|
||||
def create
|
||||
@rp_world = RpWorld.new(rp_world_params)
|
||||
|
||||
if @rp_world.save
|
||||
redirect_to @rp_world, notice: 'Rp world was successfully created.'
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /rp_worlds/1
|
||||
def update
|
||||
if @rp_world.update(rp_world_params)
|
||||
redirect_to @rp_world, notice: 'Rp world was successfully updated.'
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /rp_worlds/1
|
||||
def destroy
|
||||
@rp_world.destroy
|
||||
redirect_to rp_worlds_url, notice: 'Rp world was successfully destroyed.'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_rp_world
|
||||
@rp_world = RpWorld.includes(:wow_characters).find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def rp_world_params
|
||||
params.require(:rp_world).permit(:name, :description)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// that code so it'll be compiled.
|
||||
|
||||
import Rails from "@rails/ujs"
|
||||
import Turbolinks from "turbolinks"
|
||||
import "@hotwired/turbo-rails"
|
||||
import * as ActiveStorage from "@rails/activestorage"
|
||||
import "channels"
|
||||
|
||||
@@ -20,5 +20,4 @@ document.addEventListener("turbolinks:load", () => {
|
||||
})
|
||||
|
||||
Rails.start()
|
||||
Turbolinks.start()
|
||||
ActiveStorage.start()
|
||||
|
||||
15
app/views/rp_worlds/_form.html.erb
Normal file
15
app/views/rp_worlds/_form.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<%= form_with(model: rp_world) do |form| %>
|
||||
<div class="field">
|
||||
<%= form.label :name %>
|
||||
<%= form.text_field :name %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :description %>
|
||||
<%= form.text_field :description %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/rp_worlds/edit.html.erb
Normal file
6
app/views/rp_worlds/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing Rp World</h1>
|
||||
|
||||
<%= render 'form', rp_world: @rp_world %>
|
||||
|
||||
<%= link_to 'Show', @rp_world %> |
|
||||
<%= link_to 'Back', rp_worlds_path %>
|
||||
@@ -1,18 +1,27 @@
|
||||
<h2>Characters list</h2>
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<table class="table table-hover table-dark table-image">
|
||||
<h1>Rp Worlds</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><%= t('rp_worlds.world_list.name') %></th>
|
||||
<th scope="col"><%= t('rp_worlds.world_list.description') %></th>
|
||||
<th><%= t('rp_worlds.world_list.name') %></th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @rp_worlds.each do |world| %>
|
||||
<tr>
|
||||
<td><%= link_to world.name, world %></td>
|
||||
<td><%= world.description %></td>
|
||||
</tr>
|
||||
<% @rp_worlds.each do |rp_world| %>
|
||||
<tr>
|
||||
<td><%= rp_world.name %></td>
|
||||
<td><%= link_to 'Show', rp_world %></td>
|
||||
<td><%= link_to 'Edit', edit_rp_world_path(rp_world) %></td>
|
||||
<td><%= link_to 'Destroy', rp_world, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Rp World', new_rp_world_path %>
|
||||
|
||||
5
app/views/rp_worlds/new.html.erb
Normal file
5
app/views/rp_worlds/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New Rp World</h1>
|
||||
|
||||
<%= render 'form', rp_world: @rp_world %>
|
||||
|
||||
<%= link_to 'Back', rp_worlds_path %>
|
||||
@@ -1,3 +1,5 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-5">
|
||||
<div class="card">
|
||||
@@ -15,3 +17,6 @@
|
||||
<h1>Suite...</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= link_to 'Edit', edit_rp_world_path(@rp_world) %> |
|
||||
<%= link_to 'Back', rp_worlds_path %>
|
||||
|
||||
Reference in New Issue
Block a user