Hello, there is a user with admin rights, for him there is a button on the site for adding a new user. This button calls this form:

= simple_form_for User.new do |f| = f.error_notification .form-inputs = f.input :email, required: true, autofocus: true = f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) = f.input :password_confirmation, required: true = f.input :login, required: true = f.label :date_of_birth, class:"control-group" = f.text_field :date_of_birth, class:"form-control datepicker", required: true = f.input :country, as: :select, collection: ActionView::Helpers::FormOptionsHelper::COUNTRIES = f.input :city, required: true = f.input :address, required: true = f.input :avatar .form-actions = f.button :submit, "Sign up" 

For authorization I use the Devise gem. The problem is that when you add a user in this way, the message "You are already signed in." Pops up. and the new user is not added.

Controller code

 class UsersController < ApplicationController def new @user = User.new end def create @user = User.new(user_params) if @user.save flash[:success] = "User was successufly created" redirect_to(:back) else render 'new' end end 

Routes:

 Rails.application.routes.draw do resources :tags resources :answers do member do put "like" => "answers#upvote" put "unlike" => "answers#downvote" end end resources :questions do member do put "like" => "questions#upvote" put "unlike" => "questions#downvote" end end get 'home/index' devise_for :users, :controllers => { :omniauth_callbacks => "callbacks", registrations: 'registrations' } get 'users/:id' => 'users#show', :as => :user resources :users, except: [:show] root 'home#index' end 
  • one
    Show the code of the controller that adds the user. And routes too. - MAXOPKA 2:57 pm
  • @MAXOPKA Posted by - Maxim Cherevatov pm
  • Chrevatov has an assumption that the create action from your controller does not work, since the devise_for method adds a route that gets the contents of the form. In routes, call devise_for :users, controllers: { omniauth_callbacks: "callbacks", registrations: 'registrations' } after all routes have been announced - MAXOPKA

0