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

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

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

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

Ruby on Rails 6

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

Q&A

1回答

3154閲覧

refile実装中で吐かれた引数エラーの解決方法

SekiKazuma

総合スコア0

Ruby

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

Ruby on Rails 6

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

0グッド

0クリップ

投稿2021/01/03 08:11

編集2021/01/03 08:23

前提・実現したいこと

Ruby3.0.0
rails6.1.0
以上の環境下でusersの編集画面にrefileでの画像アップロードを実装中にエラーを吐かれてしまいましたが、解決方法を探しても見つからないため助言をいただきたいです。

発生している問題・エラーメッセージ

ArgumentError in Users#edit wrong number of arguments (given 3, expected 2; required keyword: object)
ActionView::Template::Error (wrong number of arguments (given 3, expected 2; required keyword: object)): 10: <%= f.text_field :profile %> 11: 12: <%= f.label :profile_image %> 13: <%= f.attachment_field :profile_image %> 14: 15: <%= f.submit %> 16: app/views/users/edit.html.erb:13 app/views/users/edit.html.erb:1

該当のソースコード

app/views/users/edit.html.erb

<%= form_for @user do |f| %>   #エラー該当文 <%= f.label :username %> <%= f.text_field :username %> <%= f.label :email %> <%= f.text_field :email %> <%= f.label :profile %> <%= f.text_field :profile %> <%= f.label :profile_image %> <%= f.attachment_field :profile_image %> #エラー該当文 <%= f.submit %> <% end %>

app/models/user.rb

class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable attachment :profile_image end

app/controller/users_controller.rb

class UsersController < ApplicationController before_action :set_user, only: [:show, :edit] def index @users = User.all end def show end def edit end end private def set_user @user = User.find(params[:id]) end

Gemfile

source

1git_source(:github) { |repo| "https://github.com/#{repo}.git" } 2 3ruby '3.0.0' 4 5# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 6gem 'rails', '~> 6.1.0' 7# Use mysql as the database for Active Record 8gem 'mysql2', '~> 0.5' 9# Use Puma as the app server 10gem 'puma', '~> 5.0' 11# Use SCSS for stylesheets 12gem 'sass-rails', '>= 6' 13# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 14gem 'webpacker', '~> 5.0' 15# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 16gem 'turbolinks', '~> 5' 17# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 18gem 'jbuilder', '~> 2.7' 19# Use Redis adapter to run Action Cable in production 20# gem 'redis', '~> 4.0' 21# Use Active Model has_secure_password 22# gem 'bcrypt', '~> 3.1.7' 23 24# Use Active Storage variant 25# gem 'image_processing', '~> 1.2' 26 27# Reduces boot times through caching; required in config/boot.rb 28gem 'bootsnap', '>= 1.4.4', require: false 29 30group :development, :test do 31 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 32 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 33end 34 35group :development do 36 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 37 gem 'web-console', '>= 4.1.0' 38 # Display performance information such as SQL time and flame graphs for each request in your browser. 39 # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md 40 gem 'rack-mini-profiler', '~> 2.0' 41 gem 'listen', '~> 3.3' 42 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 43 gem 'spring' 44end 45 46group :test do 47 # Adds support for Capybara system testing and selenium driver 48 gem 'capybara', '>= 3.26' 49 gem 'selenium-webdriver' 50 # Easy installation and use of web drivers to run system tests with browsers 51 gem 'webdrivers' 52end 53 54# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 55gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 56 57gem 'devise' 58gem "refile", require: "refile/rails", github: 'manfe/refile' 59gem "refile-mini_magick", github: 'refile/refile-mini_magick' 60gem "bulma-rails"

試したこと

controller,model,gemfile等関係するファイルでのスペルミスなどの考え得る人的ミスを確認しましたが、怪しい箇所は特にない状態です。

補足情報(FW/ツールのバージョンなど)

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

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

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

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

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

guest

回答1

0

私も同じエラーで悩んでいました.
このrefileっていうライブラリ保守が今ひとつ進められてないみたいです。
https://github.com/refile/refile/issues/601
github.com/activerecord-hackery/polyamorous/issues/48
rubyのバージョンを 2.7.0以上だとうまく動かないかもしれないと思いバージョンダウンをしました。
Ruby2.6.6にしたのちにgemfileとgemも再導入し、解決しました。

投稿2021/02/23 21:41

masakifuse

総合スコア2

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.47%

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

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

質問する

関連した質問