Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][追加課題]タスクにメモ機能の追加 #22

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

litencatt
Copy link
Contributor

実装内容

  • memoテーブルの追加
  • memoのPOSTボタン追加
  • Viewへのmemo列追加

動作

  • memoをPOST後、新たなmemoをPOSTで更新される

やりたいこと

  • 入力フォームと表示をわけずに、Editボタンで入力フォームを編集できるようにしたい


create_table "tasks", force: :cascade do |t|
t.text "content"
t.integer "status", limit: 4
t.date "duedate"
t.text "memo"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails側のマイグレーションファイルがないですが、どこに行きましたか...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1 +1 @@
json.extract! @task, :id, :content, :status
json.extract! @task, :id, :content, :status :memo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruby的に文法ミス

@@ -1,11 +1,23 @@
import React from "react";
import ReactDOM from "react-dom";

export default class Task extends React.Component {
handleUpdate(e) {
e.preventDefault();
this.props.onTaskUpdate({task: {id: this.props.id, status: e.target.value}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onTaskUpdateってtaskにすべての属性を渡さなくていいんでしたっけ。どこが本体だったかな...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taskUpdate(task) {
request
.patch(this.props.url + '/' + task.task.id)
.accept('application/json')
.send(task)
.end((err, res) => {
if (err || !res.ok) {
console.error(this.props.url, status, err.toString());
} else {
this.setState({data: res.body});
}
});
}

ここですね(下も同じ)
PATCHのエントリポイントが部分的な更新を取り扱えるはずだからOKそう


create_table "tasks", force: :cascade do |t|
t.text "content"
t.integer "status", limit: 4
t.date "duedate"
t.text "memo"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@udzura
Copy link
Contributor

udzura commented Oct 18, 2016

Migrations are pending. To resolve this issue, ... が出てしまうのか...

@@ -7,9 +7,6 @@
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!

# for sqlite3 use in memory
load Rails.root.join('db/schema.rb') if ENV['CI']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あるいはここの前に ActiveRecord::Base.establish_connection するといいのかもしれない。ちょっと深追いできてないけど...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants