Note that there are some explanatory texts on larger screens.

plurals
  1. PORails + Devise + Add User
    primarykey
    data
    text
    <p>I have a problem with my Rails app login with Devise.</p> <p>I have the devise user for login and i create a new scaffold user to manage the user.</p> <p>my routes.rb are like :</p> <pre><code>devise :users resources :users </code></pre> <p>The problem is when i add a new user when i'm logged with an existent user, the data is not saved in the DB.</p> <p>if i add a new user when i'm loged out, the user are added to the DB.</p> <p>to add the new user i use this link : new_user_path. So thats mean it use the resources users</p> <p>my users_controller </p> <pre><code>def new @user = User.new end def create @user = User.new(params[:user]) if @user.save redirect_to users_url, :notice =&gt; "User created." else render :action =&gt; 'new' end end </code></pre> <p>in my application_controller i added this functionnality</p> <pre><code>def after_sign_in_path_for(resource) company_id = resource.company_id @company = Company.find(company_id) puts @company.subdomain root_url(:host =&gt; @company.subdomain + "." + request.domain + '/companies/' + @company.id.to_s) end </code></pre> <p>when i add the users when i'm loged in i have that in the server log</p> <pre><code>Processing by Devise::RegistrationsController#create as HTML Parameters: {"commit"=&gt;"Create User", "authenticity_token"=&gt;"6p7qqcu3x8WAJ7eWdtwJLeJQV1lj9IXtomtzxUpTx3k=", "utf8"=&gt;"✓", "user"=&gt;{"usersubtype_id"=&gt;"", "username"=&gt;"3423", "last_name"=&gt;"", "company_id"=&gt;"1", "password"=&gt;"[FILTERED]", "email"=&gt;"foo@bar.com", "first_name"=&gt;"", "usertype_id"=&gt;""}} User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 </code></pre> <p>i dont know why that works when i'm not logged, but not when i'm logged.</p> <p>Thanks for your ideas.</p> <p>EDIT : I checked for devise :registerable in my user model. here is what i have in my model.</p> <pre><code>devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable belongs_to :company # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :first_name, :last_name, :phone, :owner, :usertype_id, :usersubtype_id, :company_id </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload