Rails 4 - devise_for not using user controllers

I am using Devise in my Rails application and I would like to customize its behavior. I read the documentation for devise_for . But I can not get it to use my user controllers. My routes look like this:

 devise_for :users, controllers: { sessions: "users/sessions", registrations: "users/registrations" } 

In my Users::RegistrationsController < Devise::RegistrationsController I tried the following:

 # POST /resource def create puts "I'm here" # never happens! super end 

Any ideas on what I am missing?

Update

Here is my file structure: enter image description here

Update 2

I think I could find the root of the problem. I visualize and submit my registration form in the Bootstrap module on a different route than the default path.

I submit the form along this path:

 /apps/1/edit 

And not:

 users/sign_up 

If I register this users/sign_up , it works and my methods are called. In my view /apps/1/edit I present the forms as follows:

 = render "users/registrations/modal_form" 

My editing action for my apps_controller (the action in which I submit the registration form) is currently empty:

 # GET /apps/1/edit def edit end 

The relevant parts of my users/registrations/modal_form are as follows:

 .modal.fade#registrations_modal{ tabindex: -1, role: 'dialog', "aria-labelledby" [..] = render "users/registrations/new_form" [..] 

And my users/registrations/new_form looks like this:

 = form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| = devise_error_messages! .form-group = f.label :name = f.text_field :name, autofocus: true, class: "form-control" .form-group = f.label :email = f.email_field :email, class: "form-control" .form-group = f.label :password - if @minimum_password_length %em (#{@minimum_password_length} characters minimum) = f.password_field :password, autocomplete: "off", class: "form-control" .form-group = f.submit "Sign up", class: "btn btn-default" - if current_page?(new_user_registration_path) = render "devise/shared/links" 

I am not familiar with Devise. Any ideas on what and where am I missing something?

+1
ruby ruby-on-rails devise
source share
1 answer

I think I solved it. The problem was in my form_for where I used the wrong route. Instead of using the default registration_path as the url I use instead:

 user_registration_path(resource_name) 

Stupid mistake. In another problem, I keep getting: ActionController::UnknownFormat upon registration. But at least I use my user controllers.

0
source share

All Articles