Closed bricedurand closed 2 years ago
What's the exact version of RailsAdmin? Could you try these in Rails console and provide output?
RailsAdmin::Config.model(School).fields.find {|f| f.name == :school }
RailsAdmin::Config.model(School).show.fields.find {|f| f.name == :school }
Hello, thanks for taking the time to answer this.
The exact version of RailsAdmin is 3.0.0.
Here is the first output :
RailsAdmin::Config.model(School).fields.find {|f| f.name == :school }
Traceback (most recent call last):
/Users/brice/.rvm/gems/ruby-2.7.2@monstage/gems/rails_admin-3.0.0/lib/rails_admin/config/fields.rb:50:in `factory': undefined method `properties' for nil:NilClass (NoMethodError)
The second command has the same output :
RailsAdmin::Config.model(School).show.fields.find {|f| f.name == :s
chool }
Traceback (most recent call last):
/Users/brice/.rvm/gems/ruby-2.7.2@monstage/gems/rails_admin-3.0.0/lib/rails_admin/config/fields.rb:50:in `factory': undefined method `properties' for nil:NilClass (NoMethodError)
Sorry it was my mistake, there ones:
RailsAdmin::Config.model(Student).fields.find {|f| f.name == :school }
RailsAdmin::Config.model(Student).show.fields.find {|f| f.name == :school }
I want to know how RailsAdmin detects that school
field.
Ok, the Student model is in a module 'Users' so I ran it like this :
RailsAdmin::Config.model(Users::Student).fields.find {|f| f.name ==
:school }
RailsAdmin::Config.model(Users::Student).show.fields.find {|f| f.na
me == :school }
Both return nil. There are other fields but not school.
I also ran this on model School
RailsAdmin::Config.model(School).fields
and had the same error as above
Thanks. To investigate the issue I need to be able to reproduce it. Could you try creating a new Rails application and generating relevant models to reproduce? If you can upload it to a public repo or gist it will be super-helpful.
I will try with a new app but I doubt that it is the best approach, because the issue appeared from migrating an existing a code base from RailsAdmin 2.2.1 to 3.0.0. So I'd rather remove code step by step and see when it is working again.
The code is already on a public repo : https://github.com/betagouv/monstage You can try running it but you might run into issues like broken db migrations. At least you have access to the whole source code.
I'll take some time to try to reproduce this issue and help you with the project setup if you want to investigate further.
Your app was too big to be fully run, but I partially tested it and found out that with the RailsAdmin master branch the school field was correctly detected.
> RailsAdmin.config(Users::Student).fields.find{|f| f.name == :school}
=> #<RailsAdmin::Config::Fields::Types::BelongsToAssociation[school] ...>
Could you also try that?
gem 'rails_admin', '~> 3.0', github: 'railsadminteam/rails_admin'
I tried using master branch and it worked !
I also realized this issue was only happening on my local machine, and not on production. Haven't found the reason why though...
My guess is it's something related to the initialization process. I won't go further for now, since #3541 seems to work. Thank you for reporting.
Hello,
I've migrated my application from rails_admin 2.2 to 3.0 and it is usable, however some views have changed without changing the model code.
I have a Student model which belongs to a School :
Here are the changes : List view In my 2.2 list view, the school was displayed as a link, which was a nice way to navigate in the admin. Now in 3.0 list view, I lost the link :
Show view In 2.2 show view, I also had a link
And now in 3.0 show view it is just the ID :
Edit view In 2.2 edit view, there was a select box to change the school, plus a button to modify the school or add a new one.
In 3.0 edit view there is only an input with the name of the school
Is it possible to get the old display back? I haven't found anything regarding field configuration that would give me the old behaviour.