-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from TreinaDev/feature/usuario-cria-projeto
Feature/usuario cria projeto
- Loading branch information
Showing
16 changed files
with
446 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class ProjectsController < ApplicationController | ||
before_action :authenticate_user!, only: %i[new create show] | ||
before_action :set_project, only: [:show] | ||
|
||
def new | ||
@project = current_user.projects.build | ||
end | ||
|
||
def create | ||
@project = current_user.projects.build(project_params) | ||
|
||
if @project.save | ||
redirect_to project_path(@project), notice: t('.success') | ||
else | ||
flash.now[:alert] = t('.fail') | ||
render :new, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def show; end | ||
|
||
private | ||
|
||
def set_project | ||
@project = Project.find(params[:id]) | ||
end | ||
|
||
def project_params | ||
params.require(:project).permit(:title, :description, :category) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class Project < ApplicationRecord | ||
belongs_to :user | ||
has_many :user_roles, dependent: :destroy | ||
|
||
validates :title, :description, :category, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
<h1>Cola?Bora!</h1> | ||
|
||
<div id="vue-app" class="card"> | ||
<div class="card-body"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<%= form_with model: @project do |f| %> | ||
<% if @project.errors.any? %> | ||
<div class='text-danger'> | ||
<h3>Erros:</h3> | ||
<ul> | ||
<% @project.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="mb-3"> | ||
<%= f.label :title, class: 'form-label' %> | ||
<%= f.text_field :title, class: 'form-control' %> | ||
</div> | ||
<div class="mb-3"> | ||
<%= f.label :description, class: 'form-label' %> | ||
<%= f.text_field :description, class: 'form-control' %> | ||
</div> | ||
<div class="mb-3"> | ||
<%= f.label :category, class: 'form-label' %> | ||
<%= f.text_field :category, class: 'form-control' %> | ||
</div> | ||
<div> | ||
<%= f.submit 'Salvar Projeto', class: 'btn btn-primary'%> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>Novo Projeto</h1> | ||
|
||
<%= render 'form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1><%= Project.model_name.human %>: <%= @project.title %></h1> | ||
<dl> | ||
<dt><%= Project.human_attribute_name :description %>: </dt> | ||
<dd><%= @project.description %></dd> | ||
<dt><%= Project.human_attribute_name :category %>: </dt> | ||
<dd><%= @project.category %></dd> | ||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
pt-BR: | ||
activerecord: | ||
models: | ||
project: | ||
one: Projeto | ||
other: Projetos | ||
attributes: | ||
project: | ||
title: Título | ||
description: Descrição | ||
category: Categoria | ||
user_id: Usuário | ||
projects: | ||
create: | ||
success: Projeto criado com sucesso. | ||
fail: Não foi possível criar o projeto. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
pt-BR: | ||
activerecord: | ||
errors: | ||
messages: | ||
record_invalid: 'A validação falhou: %{errors}' | ||
restrict_dependent_destroy: | ||
has_one: Não é possível excluir o registro pois existe um %{record} dependente | ||
has_many: Não é possível excluir o registro pois existem %{record} dependentes | ||
date: | ||
abbr_day_names: | ||
- dom | ||
- seg | ||
- ter | ||
- qua | ||
- qui | ||
- sex | ||
- sáb | ||
abbr_month_names: | ||
- | ||
- jan | ||
- fev | ||
- mar | ||
- abr | ||
- mai | ||
- jun | ||
- jul | ||
- ago | ||
- set | ||
- out | ||
- nov | ||
- dez | ||
day_names: | ||
- domingo | ||
- segunda-feira | ||
- terça-feira | ||
- quarta-feira | ||
- quinta-feira | ||
- sexta-feira | ||
- sábado | ||
formats: | ||
default: "%d/%m/%Y" | ||
long: "%d de %B de %Y" | ||
short: "%d de %B" | ||
month_names: | ||
- | ||
- janeiro | ||
- fevereiro | ||
- março | ||
- abril | ||
- maio | ||
- junho | ||
- julho | ||
- agosto | ||
- setembro | ||
- outubro | ||
- novembro | ||
- dezembro | ||
order: | ||
- :day | ||
- :month | ||
- :year | ||
datetime: | ||
distance_in_words: | ||
about_x_hours: | ||
one: aproximadamente %{count} hora | ||
other: aproximadamente %{count} horas | ||
about_x_months: | ||
one: aproximadamente %{count} mês | ||
other: aproximadamente %{count} meses | ||
about_x_years: | ||
one: aproximadamente %{count} ano | ||
other: aproximadamente %{count} anos | ||
almost_x_years: | ||
one: quase %{count} ano | ||
other: quase %{count} anos | ||
half_a_minute: meio minuto | ||
less_than_x_seconds: | ||
one: menos de %{count} segundo | ||
other: menos de %{count} segundos | ||
less_than_x_minutes: | ||
one: menos de um minuto | ||
other: menos de %{count} minutos | ||
over_x_years: | ||
one: mais de %{count} ano | ||
other: mais de %{count} anos | ||
x_seconds: | ||
one: "%{count} segundo" | ||
other: "%{count} segundos" | ||
x_minutes: | ||
one: "%{count} minuto" | ||
other: "%{count} minutos" | ||
x_days: | ||
one: "%{count} dia" | ||
other: "%{count} dias" | ||
x_months: | ||
one: "%{count} mês" | ||
other: "%{count} meses" | ||
x_years: | ||
one: "%{count} ano" | ||
other: "%{count} anos" | ||
prompts: | ||
second: Segundo | ||
minute: Minuto | ||
hour: Hora | ||
day: Dia | ||
month: Mês | ||
year: Ano | ||
errors: | ||
format: "%{attribute} %{message}" | ||
messages: | ||
accepted: deve ser aceito | ||
blank: não pode ficar em branco | ||
confirmation: não é igual a %{attribute} | ||
empty: não pode ficar vazio | ||
equal_to: deve ser igual a %{count} | ||
even: deve ser par | ||
exclusion: não está disponível | ||
greater_than: deve ser maior que %{count} | ||
greater_than_or_equal_to: deve ser maior ou igual a %{count} | ||
in: deve estar em %{count} | ||
inclusion: não está incluído na lista | ||
invalid: não é válido | ||
less_than: deve ser menor que %{count} | ||
less_than_or_equal_to: deve ser menor ou igual a %{count} | ||
model_invalid: 'A validação falhou: %{errors}' | ||
not_a_number: não é um número | ||
not_an_integer: não é um número inteiro | ||
odd: deve ser ímpar | ||
other_than: deve ser diferente de %{count} | ||
present: deve ficar em branco | ||
required: é obrigatório(a) | ||
taken: já está em uso | ||
too_long: | ||
one: 'é muito longo (máximo: %{count} caracter)' | ||
other: 'é muito longo (máximo: %{count} caracteres)' | ||
too_short: | ||
one: 'é muito curto (mínimo: %{count} caracter)' | ||
other: 'é muito curto (mínimo: %{count} caracteres)' | ||
wrong_length: | ||
one: não possui o tamanho esperado (%{count} caracter) | ||
other: não possui o tamanho esperado (%{count} caracteres) | ||
template: | ||
body: 'Por favor, verifique o(s) seguinte(s) campo(s):' | ||
header: | ||
one: 'Não foi possível gravar %{model}: %{count} erro' | ||
other: 'Não foi possível gravar %{model}: %{count} erros' | ||
helpers: | ||
select: | ||
prompt: Por favor selecione | ||
submit: | ||
create: Criar %{model} | ||
submit: Salvar %{model} | ||
update: Atualizar %{model} | ||
number: | ||
currency: | ||
format: | ||
delimiter: "." | ||
format: "%u %n" | ||
precision: 2 | ||
separator: "," | ||
significant: false | ||
strip_insignificant_zeros: false | ||
unit: R$ | ||
format: | ||
delimiter: "." | ||
precision: 3 | ||
round_mode: default | ||
separator: "," | ||
significant: false | ||
strip_insignificant_zeros: false | ||
human: | ||
decimal_units: | ||
format: "%n %u" | ||
units: | ||
billion: | ||
one: bilhão | ||
other: bilhões | ||
million: | ||
one: milhão | ||
other: milhões | ||
quadrillion: | ||
one: quatrilhão | ||
other: quatrilhões | ||
thousand: mil | ||
trillion: | ||
one: trilhão | ||
other: trilhões | ||
unit: '' | ||
format: | ||
delimiter: '' | ||
precision: 3 | ||
significant: true | ||
strip_insignificant_zeros: true | ||
storage_units: | ||
format: "%n %u" | ||
units: | ||
byte: | ||
one: Byte | ||
other: Bytes | ||
eb: EB | ||
gb: GB | ||
kb: KB | ||
mb: MB | ||
pb: PB | ||
tb: TB | ||
percentage: | ||
format: | ||
delimiter: "." | ||
format: "%n%" | ||
precision: | ||
format: | ||
delimiter: "." | ||
support: | ||
array: | ||
last_word_connector: " e " | ||
two_words_connector: " e " | ||
words_connector: ", " | ||
time: | ||
am: am | ||
formats: | ||
default: "%a, %d de %B de %Y, %H:%M:%S %z" | ||
long: "%d de %B de %Y, %H:%M" | ||
short: "%d de %B, %H:%M" | ||
pm: pm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
# Defines the root path route ("/") | ||
root to: "home#index" | ||
resources :projects, only: [:new, :create, :show] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
FactoryBot.define do | ||
factory :project do | ||
user { nil } | ||
title { 'MyString' } | ||
description { 'MyText' } | ||
category { 'MyString' } | ||
user | ||
sequence(:title) { |n| "Padrão #{n}" } | ||
sequence(:description) { |n| "Descrição de um projeto padrão para testes #{n}." } | ||
category { 'Categoria de projeto' } | ||
end | ||
end |
Oops, something went wrong.