Prelang / feedback

8 stars 0 forks source link

Admin user form error when using Devise, ActiveAdmin and PostgreSQL #14

Open tbjers opened 9 years ago

tbjers commented 9 years ago

I just generated an application using ActiveAdmin, Devise, Formtastic, and PostgreSQL. Everything generated just fine and I fired up the application. Once I had the application running, I went to the admin interface and poked around. When I tried to create a new User, I got the following error:

Formtastic::UnknownInputError at /admin/users/new
Unable to find input class for inet

The two fields current_sign_in_ip and last_sign_in_ip are both created with the inet type in PostgreSQL. Would it be helpful for people with similar configurations if you added a custom input class for the inet field type, or simply ignore those two fields in the form?

tbjers commented 9 years ago

I solved this by adding the following custom input class:

class InetInput < Formtastic::Inputs::StringInput
end

I put this file in app/inputs/inet_input.rb and it works fine with existing users as well as new users. You may still want to auto-generate this file for when user's build their project with PostgreSQL, ActiveAdmin and Formtastic so that the page doesn't crash.

arnaudbouffard commented 9 years ago

Rails 4.1.1, PG, devise and activeadmin, exactly same issue here when either editing existing user or creating new one.

@tbjers solution worked for me

karamosky commented 9 years ago

@tbjers Thank you very much that worked for me too

stephen-puiszis commented 9 years ago

@tbjers Worked as well, thank you

eriknomitch commented 9 years ago

@tbjers Thanks for the fix. I will have Prelang inject that file.

tbjers commented 9 years ago

@eriknomitch No problem. Glad I could be of assistance!

Joseworks commented 9 years ago

Thank you very much @tbjers , that worked out for me as well.

sbstn-jmnz commented 9 years ago

Thank you very much @tbjers , that worked out for me as well

eriknomitch commented 9 years ago

Reopening since I haven't had time to implement the fix. See this disclaimer as to why.

IvikGH commented 9 years ago

Hi, all. This helped me too. But there is similar error "Unable to find input class HstoreInput". Fixed it in the similar way - added file /app/inputs/hstore_input.rb class HstoreInput < Formtastic::Inputs::TextInput end

ghost commented 9 years ago

worked for me too! thanks

joshillian commented 9 years ago

Appreciate the fix, Torgny. Extremely helpful!

noxs-jj commented 9 years ago

Perfect solution +1 Thanks

huntjessica commented 9 years ago

Yea this worked for me! Awesome!!

abhinaykumar commented 8 years ago

Please consider adding this solution https://github.com/Prelang/feedback/issues/14#issuecomment-63241267 by default in the gem.

IvikGH commented 8 years ago

Great idea !!!

wolfieorama commented 8 years ago

I like it ... saved me 3 days of pain :)

pldk commented 8 years ago

thanks @tbjers, you've fixed my day :)

SylarRuby commented 8 years ago

@tbjers +1 in 2016 for this that solves money-rails gem! Thanks!

Joseworks commented 8 years ago

Hi guys, On the same tune...again. I was having dependency issues with # gem 'active_admin_editor', github: 'ejholmes/active_admin_editor'. and getting the error "Unable to find input class HtmlEditorInput"

Fixed it in the similar way - added the file /app/inputs/html_editor_input.rb

class HtmlEditorInput < Formtastic::Inputs::TextInput end

konradrr commented 8 years ago

@tbjers Thanks for the solution, nice idea! In my opinion, even more elegant solution is moving the file into the lib directory. In my case, for jsonb, it is:

_/lib/ext/jsonbinput.rb

class JsonbInput < Formtastic::Inputs::StringInput
end

_/initializers/loadextensions.rb Dir["#{Rails.root}/lib/ext/**/*"].each { |f| require f }

Of course it also works.

martinbortowski commented 8 years ago

I have the same issue but I can't use this solution because I dont have an app/inputs/ folder or app/active_admin/inputs/ directory to create the input.rb file! I can't find the folder nowhere! My directory looks like this: app/admin/

Has someone any idea how I can get around this issue?

My workspace is the cloud9 IDE and I am using rails 5.0.0.1 and my Gemfile looks like this:

gem 'devise' 
gem 'activeadmin', github: 'activeadmin/activeadmin' 
gem 'inherited_resources', github: 'activeadmin/inherited_resources'

Thanks in advance!

konradrr commented 8 years ago

@martinbortowski The inputs isn't a standard folder. Just create it.

martinbortowski commented 8 years ago

@konradrr Thank you so much it worked! I thought that it was a standard folder!

NicholasWenzel commented 7 years ago

Hi, the solution did not work for me. I have the error message:

@input_class_finder.find(as) rescue Formtastic::InputClassFinder::NotFoundError raise Formtastic::UnknownInputError, "Unable to find input #{$!.message}" end

  # @api private

Do I need to do something else?

Ronaq13 commented 6 years ago

Hi, all. This helped me too. But there is similar error "Unable to find input class JsonInput". Fixed it in the similar way - added file /app/inputs/json_input.rb class HstoreInput < Formtastic::Inputs::TextInput end

chanakyacool commented 6 years ago

if you have an error as same as ActionView::Template::Error (Unable to find input class JsonInput)

Then this helped me app/inputs/json_input.rb class JsonInput < Formtastic::Inputs::TextInput; end

Ahmad8043 commented 6 years ago

@tbjers Thank you very much that worked for me

alexventuraio commented 5 years ago

Thanks, it still working on Rails 5.

davidadafia commented 5 years ago

@tbjers it worked. Thanks a lot