mirror of
https://github.com/Threnklyn/Klaus.git
synced 2026-05-18 20:23:28 +02:00
fügt table_grid zu documents_grid
This commit is contained in:
@@ -1,2 +1,25 @@
|
||||
class DocumentsController < ApplicationController
|
||||
def index
|
||||
@documents_grid = initialize_grid(Document)
|
||||
end
|
||||
|
||||
def new
|
||||
@document = Document.new
|
||||
end
|
||||
|
||||
def create
|
||||
@document = Document.new(document_params)
|
||||
|
||||
if @document.save
|
||||
redirect_to documents_path, notice: 'Document was successfully created.'
|
||||
else
|
||||
lash.now[:alert] = 'Document creation failed.'
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def document_params
|
||||
params.require(:document).permit(:name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
class Document < ActiveRecord::Base
|
||||
validates :name, presence: true
|
||||
end
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
= bootstrap_form_for(@document) do |f|
|
||||
= f.text_field :name
|
||||
|
||||
= f.submit
|
||||
@@ -0,0 +1,5 @@
|
||||
<%= grid(@documents_grid, upper_pagination_panel: true) do |g|
|
||||
g.column name: 'ID', attribute: 'id'
|
||||
g.column name: 'Name', attribute: 'name'
|
||||
end
|
||||
%>
|
||||
@@ -1 +1,6 @@
|
||||
| Hallo
|
||||
h1 Index
|
||||
|
||||
p
|
||||
= btn_link_to 'New', new_document_path, class: 'btn-primary'
|
||||
|
||||
= render 'grid'
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
== render 'form'
|
||||
Reference in New Issue
Block a user