Skip to content

Commit

Permalink
user signup
Browse files Browse the repository at this point in the history
  • Loading branch information
ren7087 committed Aug 8, 2021
1 parent f2ef0c1 commit 6c3e5ba
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
4 changes: 0 additions & 4 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def index
end

def show
@task = current_user.tasks.find(params[:id])
end

def new
Expand All @@ -28,11 +27,9 @@ def create
end

def edit
@task = current_user.tasks.find(params[:id])
end

def update
@task = current_user.tasks.find(params[:id])
if @task.update(task_params)
flash[:success] = 'Task は正常に更新されました'
redirect_to @task
Expand All @@ -43,7 +40,6 @@ def update
end

def destroy
@task = current_user.tasks.find(params[:id])
@task.destroy
flash[:success] = 'Task は正常に削除されました'
redirect_to tasks_url
Expand Down
1 change: 0 additions & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Task < ApplicationRecord
belongs_to :user
validates :user_id, presence: true, length: { maximum: 255 }
validates :content, presence: true, length: { maximum: 255 }
validates :status, presence: true, length: {maximum: 10}
end
5 changes: 3 additions & 2 deletions app/views/layouts/_error_messages.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<% if @task.errors.any? %>
<% if model.errors.any? %>
<%#= model.errors.count %>
<div id="error_explanation" class="alert alert-warning">
<ul class="mb-0">
<% task.errors.full_messages.each do |msg| %>
<% model.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion app/views/tasks/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= form_with(model: task) do |f| %>
<%= render 'layouts/error_messages' %>
<%= render 'layouts/error_messages', model: f.object %>

<%= f.label :status, 'ステータス' %>
<%= f.text_field :status %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="col-sm-6 offset-sm-3">

<%= form_with(model: @user) do |f| %>
<%= render 'layouts/error_messages', model: f.object %>

<div class="mb-3">
<%= f.label :name, 'Name' %>
Expand Down

0 comments on commit 6c3e5ba

Please sign in to comment.