Skip to content

Commit

Permalink
Agregar funcionalidad: Documento pueda ser público o privado
Browse files Browse the repository at this point in the history
  • Loading branch information
KattyaCuevas committed Aug 18, 2022
1 parent 1bb33e3 commit caa961c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ Agregar modelos
```
$ rails g model Workspace owner:references title
$ rails g model Document workspace:references owner:references title content:rich_text
```

Documento pueda ser público o privado
```
$ rails g migration AddPublicToDocuments public:boolean
```
2 changes: 1 addition & 1 deletion app/controllers/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def set_document

# Only allow a list of trusted parameters through.
def document_params
params.require(:document).permit(:title, :content)
params.require(:document).permit(:title, :content, :public)
end
end
3 changes: 3 additions & 0 deletions app/views/documents/_document.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div id="<%= dom_id document %>">
<!-- TODO: Add helper to generate tags -->
<p><%= document.public ? 'Público' : 'Privado' %></p>

<p class="my-5">
<strong class="block font-medium mb-1">Título:</strong>
<%= document.title %>
Expand Down
5 changes: 5 additions & 0 deletions app/views/documents/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<%= form.rich_text_area :content %>
</div>

<div class="my-5">
<%= form.label :public %>
<%= form.check_box :public %>
</div>

<div class="inline">
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
</div>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20220818002605_add_public_to_documents.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPublicToDocuments < ActiveRecord::Migration[7.0]
def change
add_column :documents, :public, :boolean, default: true
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit caa961c

Please sign in to comment.