Administrate: `has_one?' for nil:NilClass (NoMethodError)

Created on 18 Feb 2018  路  19Comments  路  Source: thoughtbot/administrate

Environments:

  • ruby 2.4.2p198
  • Rails 5.1.1

After a fresh install, I get this error when I run the install generator.

`association_type': undefined method `has_one?' for nil:NilClass (NoMethodError)
install models

Most helpful comment

I don't have any gems, just the new active storage!

All 19 comments

@woniesong92 with fresh install do you mean Administrate or Rails? The error is raised from here, it looks like your model association aren't properly setup. Can you post them here so we can take a look?

Ping @woniesong92 ; can you post your model info so we can take a look?

Did anyone figure out the solution to this?

I was using Globalize on the model in question. If I removed translates :name it worked.

the same issue. ruby 2.5.1, rails 5.2.1

because of acts-as-taggable-on gem

Hey! I'm having the same issue. Any plans to merge this PR?

This issue sounds like it has potentially a bunch a root causes, with paperclip, acts-as-taggable-on and others mentioned too.

Would someone with this issue be able to create an example app one of us could look at?

I don't have any gems, just the new active storage!

It seems like active storage is causing this issue for me.

Update: Looks like it's this issue: #975

FWIW, I'm running into the same problem. Not using Paperclip or Active Storage.

I tried removing all belongs_to and has_many, but no luck. It _might_ be related to a _string_ column called foobar_id which is not a reference to another model, but something external to the app. (e.g. _tweet_id_ when referring to Twitter's own tweet identifier).

rails (5.2.1.1)
administrate (0.11.0)

In my case, the cause was the new Rails 5 attribute API. Worked by commenting those while generating the dashboard.

Having the same issue trying to implement Administrate with ActiveStorage. Fails at the association of has_one_attached :image

same issue

I've just merged #1290, which I'm hoping fixes this problem for a bunch of you.

For those with the same issue, could you try current master and report back? I'll close this in two weeks (by 2019-04-30), but if it's still an issue we can open another one.

@nickcharlton just used the master branch and it seems to install however still get this error for attached images

uninitialized constant ImageAttachmentDashboard

Okay. I'm going to close this for now, but could you open a new issue? Perhaps with a demo app which I can have a look at?

For future visitors looking for the quickfix: gem "administrate", git: "https://github.com/thoughtbot/administrate"

I commented acts_as_taggable_on :tags in my model while I ran the generator and it worked fine. Just uncommented the offending lines when it was done.

Using gem 'administrate', '~> 0.10.0'

Confirming that @therealrodk's solution worked for me as well.

Thanks bro!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MatthiasRMS picture MatthiasRMS  路  3Comments

ACPK picture ACPK  路  4Comments

drewtunney picture drewtunney  路  3Comments

Reedian picture Reedian  路  4Comments

rmarronnier picture rmarronnier  路  4Comments