質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

2195閲覧

Rails4 一つのカラムだけ保存できていない

smith

総合スコア73

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2014/12/25 06:59

sub_category_idだけデータ保存ができていません
ログを見る限りpostはできています。

lang

1 2 <div class="form-group"> 3 <label for="category_id" class="col-sm-3 control-label">カテゴリ</label> 4 <div class="col-sm-9"> 5 6 <%= f.select :category_id, options_for_select(@categories.collect { |category| 7 [category.name, category.code] }), {:prompt => '選択してください' }, { id: 'category_select' } %> 8 9 <br> 10 <%= f.select :sub_category_id, options_for_select(@childs.collect { |child| 11 [child.name, child.code] }), {:prompt => '選択してください' }, { id: 'child_select'} %> 12 </div> 13 </div>

Started GET "/items/categoreis/list?code=0050000" for 127.0.0.1 at 2014-12-25 15:56:04 +0900
Processing by ItemsController#list as JSON
Parameters: {"code"=>"0050000", "id"=>"categoreis"}
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 [["id", 1]]
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 1]]
Category Load (0.3ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 959348699]]
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."code" = '0050000' ORDER BY "categories"."id" ASC LIMIT 1
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 8375840]]
Completed 200 OK in 7ms (Views: 0.3ms | ActiveRecord: 0.9ms)

Started POST "/items" for 127.0.0.1 at 2014-12-25 15:56:23 +0900
Processing by ItemsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"CAGywR41IZ09yDTBpXLHbZ2FUU1WdnNil8NotYILPSs=", "item"=>{"category_id"=>"0050000", "sub_category_id"=>"0500500", "picture1"=>#<ActionDispatch::Http::UploadedFile:0x007fa867813910 @tempfile=#Tempfile:/var/folders/l7/507yf4tj3yd7mjxxgschz5y00000gn/T/RackMultipart20141225-3132-zjndca, @original_filename="bapewomens_01_thumb.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name="item[picture1]"; filename="bapewomens_01_thumb.jpg"\r\nContent-Type: image/jpeg\r\n">, "title"=>"qq", "content"=>"q", "condition"=>"qq", "area"=>"qq", "limit_day(1i)"=>"2014", "limit_day(2i)"=>"12", "limit_day(3i)"=>"25"}, "commit"=>"送信"}
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 [["id", 1]]
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 1]]
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 959348699]]
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Unpermitted parameters: sub_category_id
CACHE (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 [["id", 1]]
CACHE (0.0ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 1]]
CACHE (0.0ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 959348699]]
(0.1ms) begin transaction
SQL (0.3ms) INSERT INTO "items" ("area", "category_id", "condition", "content", "created_at", "limit_day", "picture1", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["area", "qq"], ["category_id", 50000], ["condition", "qq"], ["content", "q"], ["created_at", "2014-12-25 06:56:23.364849"], ["limit_day", "2014-12-25"], ["picture1", "bapewomens_01_thumb.jpg"], ["title", "qq"], ["updated_at", "2014-12-25 06:56:23.364849"], ["user_id", 1]]
(0.7ms) commit transaction
Redirected to http://0.0.0.0:3000/items/35
Completed 302 Found in 248ms (ActiveRecord: 1.9ms)

Started GET "/items/35" for 127.0.0.1 at 2014-12-25 15:56:23 +0900
Processing by ItemsController#show as HTML
Parameters: {"id"=>"35"}
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" = ? LIMIT 1 [["id", 1]]
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 1]]
Category Load (0.1ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = ? [["parent_id", 959348699]]
Item Load (0.1ms) SELECT "items".* FROM "items" WHERE "items"."id" = ? LIMIT 1 [["id", 35]]
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Comment Load (0.1ms) SELECT "comments".* FROM "comments" WHERE "comments"."item_id" = ? ORDER BY "comments"."created_at" ASC [["item_id", 35]]
User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]]
Profile Load (0.1ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = ? LIMIT 1 [["user_id", 1]]
Rendered items/show.html.erb within layouts/application (10.7ms)
CACHE (0.0ms) SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = ? LIMIT 1 [["user_id", 1]]
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."parent_id" = 1
Completed 200 OK in 384ms (Views: 378.9ms | ActiveRecord: 1.1ms)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

ストロングパラメーター

投稿2014/12/25 13:40

smith

総合スコア73

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問