fügt table_grid zu documents_grid

This commit is contained in:
Florian Bogenhard
2014-08-08 23:50:46 +02:00
parent 8ee68cecce
commit 4a1a0937d4
6 changed files with 40 additions and 1 deletions
+23
View File
@@ -1,2 +1,25 @@
class DocumentsController < ApplicationController 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 end
+1
View File
@@ -1,2 +1,3 @@
class Document < ActiveRecord::Base class Document < ActiveRecord::Base
validates :name, presence: true
end end
+4
View File
@@ -0,0 +1,4 @@
= bootstrap_form_for(@document) do |f|
= f.text_field :name
= f.submit
+5
View File
@@ -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
%>
+6 -1
View File
@@ -1 +1,6 @@
| Hallo h1 Index
p
= btn_link_to 'New', new_document_path, class: 'btn-primary'
= render 'grid'
+1
View File
@@ -0,0 +1 @@
== render 'form'