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

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

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

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

Ruby on Rails

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

Q&A

0回答

1455閲覧

active admin でArgumentError in Admin::Products#show

pepper

総合スコア29

Ruby

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

Ruby on Rails

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

0グッド

0クリップ

投稿2016/12/17 16:26

active adminを導入してからタイトルのようなエラーが出ます。

Showing /Users//.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/activeadmin-4f494073c6c0/app/views/active_admin/resource/show.html.arb where line #2 raised: wrong number of arguments (given 1, expected 0) temp_method = "__temp__#{safe_name}" ActiveRecord::AttributeMethods::AttrNames.set_name_cache safe_name, name @module.module_eval method_body(temp_method, safe_name), __FILE__, __LINE__ @module.instance_method temp_method end end

今まではこのようなエラーが出たことがなかったので、どう対処していいのかわかりません。

現状だと
・他のモデルからはデータを登録して、その後showページで確認ができる
・Product modelも投稿画面から新しいデータを作成をできる(しかし、showページが出てくることがなくエラーが出る)

Product モデルのみでこのようなエラーが出るので、モデル周辺に問題があるかと思うのですが、もしわかる方がいらっしゃいましたら、教えていただけると嬉しいです。

こちらがモデルとactive adminのコードです。

admin

1ActiveAdmin.register Product do 2 3 #indexページ 4 index do 5 selectable_column 6 id_column 7 # column :image do |b| 8 # image_tag(b.image.url(:thumb)) 9 # end 10 column :model 11 column :method 12 column :height 13 column :width 14 column :depth 15 column :pitch 16 column :accuracy 17 column :updated_at 18 actions 19 end 20 21 # #showページ 22 show do 23 attributes_table do 24 row :model 25 row :price 26 row :method 27 row :height 28 row :width 29 row :depth 30 row :agency 31 row :pitch 32 row :accuracy 33 row :created_at 34 row :updated_at 35 end 36 end 37 38 #formのコード 39 form do |f| 40 f.inputs 'プリンター' do 41 f.input :model 42 f.input :price 43 f.input :method 44 f.input :height 45 f.input :width 46 f.input :depth 47 f.input :agency 48 f.input :pitch 49 f.input :accuracy 50 f.has_many :product_makers, allow_destroy: true, new_record: true do |t| 51 t.input :maker_id, 52 label: 'メーカー', 53 as: :select, 54 collection: Maker.all 55 end 56 f.has_many :product_uses, allow_destroy: true, new_record: true do |t| 57 t.input :use_id, 58 label: '用途', 59 as: :select, 60 collection: Use.all 61 end 62 f.actions 63 end 64 end 65 permit_params :model, :price, :method, :height, :width, :depth, :agency, :pitch, :accuracy, 66 product_makers_attributes: [:id, :maker_id], 67 product_uses_attributes: [:id, :use_id] 68end 69

product

1 2 3class Product < ActiveRecord::Base 4 has_many :product_uses 5 has_many :uses, :through => :product_uses 6 accepts_nested_attributes_for :product_uses, :allow_destroy => true 7 8 has_many :product_makers 9 has_many :makers, :through => :product_makers 10 accepts_nested_attributes_for :product_makers, :allow_destroy => true 11 12end 13 14

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

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

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

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問