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

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

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

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

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

Q&A

解決済

1回答

2974閲覧

rails6 の新機能 Action Textができない

yamada_yuuki

総合スコア100

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

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

0グッド

0クリップ

投稿2019/12/24 09:00

編集2019/12/24 09:06

rails6にアップデートをしてから、Action Textを試したのですが上手くできません。もしかしたら、Action Textは関係なくモデルの問題かもしれませんがよろしくおねがいしますm(_ _)m。

migrateerror

1rails aborted! 2StandardError: An error has occurred, this and all later migrations canceled: 3 4SQLite3::SQLException: table "active_storage_blobs" already exists 5C:/Users/user/Desktop/UG/db/migrate/20191224082803_create_active_storage_tables.active_storage.rb:4:in `change' 6bin/rails:4:in `require' 7bin/rails:4:in `<main>' 8 9Caused by: 10ActiveRecord::StatementInvalid: SQLite3::SQLException: table "active_storage_blobs" already exists 11C:/Users/user/Desktop/UG/db/migrate/20191224082803_create_active_storage_tables.active_storage.rb:4:in `change' 12bin/rails:4:in `require' 13bin/rails:4:in `<main>' 14 15Caused by: 16SQLite3::SQLException: table "active_storage_blobs" already exists 17C:/Users/user/Desktop/UG/db/migrate/20191224082803_create_active_storage_tables.active_storage.rb:4:in `change' 18bin/rails:4:in `require' 19bin/rails:4:in `<main>' 20Tasks: TOP => db:migrate 21(See full trace by running task with --trace)

マイグレーション実行時のエラーです。
なぜかファイルはもうある、的なことが書かれていますがマイグレーションファイルを見たところactive_storage_blobsというファイルは今回作ったものしかありませんでした。

Terminalerror

1Started GET "/samples/new" for ::1 at 2019-12-24 18:00:34 +0900 2 (1.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC 3 4ActiveRecord::PendingMigrationError ( 5 6Migrations are pending. To resolve this issue, run: 7 8 rails db:migrate RAILS_ENV=development 9 10): 11 12(省略)

railsactiontextinstall

1DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must 2now accept two parameters, the view object and the source for the view object. 3Change: 4 >> Coffee::Rails::TemplateHandler.call(template) 5To: 6 >> Coffee::Rails::TemplateHandler.call(template, source) 7 (called from <top (required)> at C:/Users/user/Desktop/UG/Rakefile:6) 8DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must 9now accept two parameters, the view object and the source for the view object. 10Change: 11 >> Coffee::Rails::TemplateHandler.call(template) 12To: 13 >> Coffee::Rails::TemplateHandler.call(template, source) 14 (called from <top (required)> at C:/Users/user/Desktop/UG/Rakefile:6) 15Copying actiontext.scss to app/assets/stylesheets 16 create app/assets/stylesheets/actiontext.scss 17Copying fixtures to test/fixtures/action_text/rich_texts.yml 18 create test/fixtures/action_text/rich_texts.yml 19Copying blob rendering partial to app/views/active_storage/blobs/_blob.html.erb 20 create app/views/active_storage/blobs/_blob.html.erb 21Installing JavaScript dependencies 22 run yarn add trix@^1.0.0 @rails/actiontext@^6.0.1 from "." 23WARNING: Action Text can't locate your JavaScript bundle to add its package dependencies. 24 25Add these lines to any bundles: 26 27require("trix") 28require("@rails/actiontext") 29 30Alternatively, install and setup the webpacker gem then rerun `bin/rails action_text:install` 31to have these dependencies added automatically. 32 33Copied migration 20191224082803_create_active_storage_tables.active_storage.rb from active_storage 34Copied migration 20191224082804_create_action_text_tables.action_text.rb from action_text

gem

1gem 'image_processing'←これを追加した。

細かい設定は一切していません。インストールをして使おうとしただけです。

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

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

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

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

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

guest

回答1

0

ベストアンサー

「ファイルはもうある」ではなく、DBに「tableはもうできている」です。
ファイル名は違うが active_storage_blobs をつくるmigrationがすでに実行されている
か、
migrationを使わずに作られているか
です。
もしdatabaseを作りなおしてもよい(必要なデータは入れられる)のでしたら
rails db:drop
rails db:create
rails db:migrate
して作りなおすのが一番簡単です。

そういうわけには行かない場合は。。。。
grep active_storage_blobs db/migrate/*.rb
して結果を見せてください

投稿2019/12/24 12:06

winterboum

総合スコア23331

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

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

yamada_yuuki

2019/12/25 03:23

エラーの読み方を間違えていましたね。すみません。それはそうと、grep active_storage_blobs db/migrate/*.rbの実行結果ですがこのような結果になりました。 db/migrate/20191224082803_create_active_storage_tables.active_storage.rb: create_table :active_storage_blobs do |t| db/migrate/20191224082803_create_active_storage_tables.active_storage.rb: t.foreign_key :active_storage_blobs, column: :blob_id 一応、該当のファイルの内容を書いときます。 class CreateActiveStorageTables < ActiveRecord::Migration[5.2] def change create_table :active_storage_blobs do |t|  ← t.string :key, null: false t.string :filename, null: false t.string :content_type t.text :metadata t.bigint :byte_size, null: false t.string :checksum, null: false t.datetime :created_at, null: false t.index [ :key ], unique: true end create_table :active_storage_attachments do |t| t.string :name, null: false t.references :record, null: false, polymorphic: true, index: false t.references :blob, null: false t.datetime :created_at, null: false t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true t.foreign_key :active_storage_blobs, column: :blob_id  ← end end end ←これをつけたところがgrep active_storage_blobs db/migrate/*.rbを実行して検出された部分です。 わかった事があれば何でも言ってください。お願いします。
winterboum

2019/12/25 04:09

これを見るとmigrationにはactive_storage_blobsは1回しかないですね。 削除してしまったのでなければ。 rails db:migrate:status の結果を見せてください rails db:schema:dump して、db/shcema.rb に active_storage_blobsがあるか確認してください
yamada_yuuki

2019/12/25 04:22

回答ありがとうございます。 rails db:migrate:status の実行結果です。 PS C:\Users\user\Desktop\UG> rails db:migrate:status DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must now accept two parameters, the view object and the source for the view object. Change: >> Coffee::Rails::TemplateHandler.call(template) To: >> Coffee::Rails::TemplateHandler.call(template, source) (called from <top (required)> at C:/Users/user/Desktop/UG/Rakefile:6) database: db/development.sqlite3 Status Migration ID Migration Name -------------------------------------------------- up 20190816073321 Create people up 20190902215023 ********** NO FILE ********** up 20190903105214 ********** NO FILE ********** up 20190918110448 Create posts up 20190919123318 Create messages up 20190923025017 Create blogconfigs up 20190923025236 Create bloggenres up 20190923025848 Create blogposts up 20191006073545 ********** NO FILE ********** up 20191012101640 Create mycontacts up 20191013032319 Create questions up 20191013032504 Create answers up 20191013093333 ********** NO FILE ********** up 20191014110313 ********** NO FILE ********** up 20191017061605 Devise create accounts up 20191018125326 Create questionaries up 20191018125605 Create questionary items up 20191018125810 Create questionary choices up 20191018130009 Create questionary results up 20191020040904 ********** NO FILE ********** up 20191020044200 ********** NO FILE ********** up 20191024113518 ********** NO FILE ********** up 20191024113846 ********** NO FILE ********** up 20191025112448 ********** NO FILE ********** up 20191027012839 ********** NO FILE ********** up 20191027125148 Devise create myblogs up 20191029073203 Devise create logins up 20191029074630 ********** NO FILE ********** up 20191029074933 Add name to login up 20191031074224 ********** NO FILE ********** up 20191031083043 ********** NO FILE ********** up 20191031090729 ********** NO FILE ********** up 20191031092941 ********** NO FILE ********** up 20191031093304 ********** NO FILE ********** up 20191031103623 Create ugblogs up 20191104120551 Add img to ugblog up 20191110092819 ********** NO FILE ********** up 20191110092820 ********** NO FILE ********** up 20191111090940 ********** NO FILE ********** up 20191111093225 ********** NO FILE ********** up 20191111113454 ********** NO FILE ********** up 20191113123128 Create ugsamas up 20191117011947 Add video to post up 20191117012704 Add video to ugblog up 20191117094601 Create data pages up 20191118100640 Create samples up 20191119113323 Devise create cooks up 20191119114733 Add name to cooks up 20191120105215 Create cuisines up 20191121093219 ********** NO FILE ********** up 20191123015853 ********** NO FILE ********** up 20191129075400 ********** NO FILE ********** up 20191129081912 Create meetings up 20191129113915 Add kome to meetings up 20191201003312 ********** NO FILE ********** up 20191203085619 ********** NO FILE ********** up 20191205091525 ********** NO FILE ********** up 20191206045419 Add answer to meetings up 20191207092233 Devise create oioiios up 20191207093211 Add name to oioiios up 20191211002409 ********** NO FILE ********** up 20191211004157 ********** NO FILE ********** up 20191211084820 ********** NO FILE ********** up 20191211085106 ********** NO FILE ********** up 20191211085304 ********** NO FILE ********** up 20191214115302 Create messags up 20191215024621 Create rooms up 20191217070255 ********** NO FILE ********** up 20191219050519 ********** NO FILE ********** up 20191224072652 ********** NO FILE ********** down 20191224082803 Create active storage tablesactive storage down 20191224082804 Create action text tablesaction text あと、rails db:schema:dumpの結果ですが、active_storage_blobsはあると思います。このようなことが書き加えられていました。 create_table "active_storage_blobs", force: :cascade do |t| t.string "key", null: false t.string "filename", null: false t.string "content_type" t.text "metadata" t.bigint "byte_size", null: false t.string "checksum", null: false t.datetime "created_at", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end 何度も申し訳ありませんがわかった事があれば何でもください。お願いします。
winterboum

2019/12/25 04:31

No fileがたくさんありますね。そのどこかで作ったのでしょう。 schema.rb の内容で良いのでしたら 20191224082803 Create active storage tablesactive storageは削除。 修正が必要でしたら 20191224082803 Create active storage tablesactive storageの中身を create から修正内容に変更ですね
yamada_yuuki

2019/12/25 05:42 編集

schema.rbのものでいいと思い、ファイルを削除したらNoMethodError が出てしまいました。もちろん「has_rich_text :content」は記入済みです。エラーには<%= form.rich_text_field :content %>を<%=form.rich_text_area :content %>にしろ、と書かれていましたがやってみると起動はしますがActiontextができていませんでした。おそらくschema.rbのものがだめなんだと思ったので create から修正内容に変更しようとしいたのですがやり方がわかりません。やり方を教えて下さい。お願いします。
yamada_yuuki

2019/12/25 06:59

すみません。もうdatabaseを作り直しても良いと思い rails db:drop rails db:create rails db:migrate をやったらエラーが無くなりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問