質問編集履歴
6
user\.rb追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -194,4 +194,11 @@
|
|
194
194
|
end
|
195
195
|
|
196
196
|
end
|
197
|
+
```
|
198
|
+
|
199
|
+
user.rb
|
200
|
+
```ruby
|
201
|
+
class User < ApplicationRecord
|
202
|
+
has_secure_password
|
203
|
+
end
|
197
204
|
```
|
5
schema\.rbの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -151,4 +151,47 @@
|
|
151
151
|
DELETE /login(.:format) logins#destroy
|
152
152
|
|
153
153
|
```
|
154
|
-
routes.rbを訂正しました。
|
154
|
+
routes.rbを訂正しました。
|
155
|
+
|
156
|
+
schema.rb
|
157
|
+
```ruby
|
158
|
+
ActiveRecord::Schema.define(version: 20170110165330) do
|
159
|
+
|
160
|
+
create_table "questions", force: :cascade do |t|
|
161
|
+
t.integer "qid"
|
162
|
+
t.string "field"
|
163
|
+
t.text "question"
|
164
|
+
t.string "answer"
|
165
|
+
t.string "dummy1"
|
166
|
+
t.string "dummy2"
|
167
|
+
t.string "dummy3"
|
168
|
+
t.string "dummy4"
|
169
|
+
t.string "dummy5"
|
170
|
+
t.text "note"
|
171
|
+
t.float "b"
|
172
|
+
t.integer "user1", default: 0
|
173
|
+
t.integer "user2", default: 0
|
174
|
+
t.integer "user3", default: 0
|
175
|
+
t.integer "user4", default: 0
|
176
|
+
t.integer "user5", default: 0
|
177
|
+
t.integer "user6", default: 0
|
178
|
+
t.integer "user7", default: 0
|
179
|
+
t.integer "user8", default: 0
|
180
|
+
t.integer "user9", default: 0
|
181
|
+
t.integer "user10", default: 0
|
182
|
+
t.datetime "created_at", null: false
|
183
|
+
t.datetime "updated_at", null: false
|
184
|
+
end
|
185
|
+
|
186
|
+
create_table "users", force: :cascade do |t|
|
187
|
+
t.boolean "exist", default: false
|
188
|
+
t.integer "number"
|
189
|
+
t.string "name"
|
190
|
+
t.string "password_digest"
|
191
|
+
t.float "theta", default: 0.0
|
192
|
+
t.datetime "created_at", null: false
|
193
|
+
t.datetime "updated_at", null: false
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
```
|
4
routes情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -91,11 +91,23 @@
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
```
|
94
|
-
routes.rb
|
94
|
+
routes.rb(訂正)
|
95
95
|
```ruby
|
96
96
|
Rails.application.routes.draw do
|
97
|
+
get 'questions/index'
|
98
|
+
|
99
|
+
get 'questions/show'
|
100
|
+
|
101
|
+
get 'questions/ajax_method'=>'questions#ajax_method',as:'ajax_method'
|
102
|
+
|
103
|
+
get 'questions/button'=>'questions#button',as:'button'
|
104
|
+
|
97
105
|
root 'logins#index'
|
98
106
|
resource :login, only: %i{show create destroy}
|
107
|
+
|
108
|
+
#rake routes
|
109
|
+
|
110
|
+
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
99
111
|
end
|
100
112
|
```
|
101
113
|
|
@@ -125,4 +137,18 @@
|
|
125
137
|
end
|
126
138
|
end
|
127
139
|
end
|
128
|
-
```
|
140
|
+
```
|
141
|
+
bundle exec rake routes実行結果
|
142
|
+
```ここに言語を入力
|
143
|
+
Prefix Verb URI Pattern Controller#Action
|
144
|
+
questions_index GET /questions/index(.:format) questions#index
|
145
|
+
questions_show GET /questions/show(.:format) questions#show
|
146
|
+
ajax_method GET /questions/ajax_method(.:format) questions#ajax_method
|
147
|
+
button GET /questions/button(.:format) questions#button
|
148
|
+
root GET / logins#index
|
149
|
+
login POST /login(.:format) logins#create
|
150
|
+
GET /login(.:format) logins#show
|
151
|
+
DELETE /login(.:format) logins#destroy
|
152
|
+
|
153
|
+
```
|
154
|
+
routes.rbを訂正しました。
|
3
モデル情報の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -103,4 +103,26 @@
|
|
103
103
|
newアクションで@userを作成しているのですがnilといわれてしまいます。
|
104
104
|
|
105
105
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
106
|
-
Rails 5.0.0.1
|
106
|
+
Rails 5.0.0.1
|
107
|
+
|
108
|
+
###追記
|
109
|
+
マイグレーションファイル(20170110165330_create_users.rb)
|
110
|
+
```ruby
|
111
|
+
class CreateUsers < ActiveRecord::Migration[5.0]
|
112
|
+
def change
|
113
|
+
create_table :users do |t|
|
114
|
+
|
115
|
+
t.boolean :exist,default: false
|
116
|
+
|
117
|
+
t.integer :number
|
118
|
+
|
119
|
+
t.string :name
|
120
|
+
t.string :password_digest
|
121
|
+
|
122
|
+
t.float :theta,default: 0.0
|
123
|
+
|
124
|
+
t.timestamps
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
2
タイトル変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
Railsのform_forで"First argument in form cannot contain nil or be empty"
|
body
CHANGED
File without changes
|
1
文修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -100,7 +100,7 @@
|
|
100
100
|
```
|
101
101
|
|
102
102
|
###試したこと
|
103
|
-
newアクション
|
103
|
+
newアクションで@userを作成しているのですがnilといわれてしまいます。
|
104
104
|
|
105
105
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
106
106
|
Rails 5.0.0.1
|