title: Rails create record if user created
body: <p>If new user signs up, automatically create a job_app status for him. Whole database is on mysql, I have nothing connected with the issue in <code>User model</code> (only validation and <code>has_one</code> ) The problem is that the new record in job_apps with <code>user_id = current_user.user_id</code> does not create (sincerely I don't know how to do this).</p>
  
  <pre><code>class UsersController &lt; ApplicationController
      include job_apps_helper
      def new
          @users = User.new
      end
  
      def create
          @user = User.new(user_params)
          if @user.save 
              session[:user_id] = @user.id 
              current_user = @user.id
  
              redirect_to '/status' 
          else 
              redirect_to '/signup' 
          end 
      end
      private
          def user_params
          params.require(:user).permit(:first_name, :last_name, :email, :PESEL, :phone, :cv, :password)
          end
  end
  
  
  class JobAppsController &lt; ApplicationController
      before_action :require_user, only: [:index]
      before_action :require_emp, only: [:empl]
      #def new 
      #   @job_app = job_app.new
      #end
  
      def index 
          @users = User.includes(:job_apps)
          end
          def empl
              @users = User.all.where(:user_type =&gt; 'candidate')
          end
  
      end
  class JobApp &lt; ActiveRecord::Base
      belongs_to :user dependent: :create, :destroy
      enum status: [ :waiting, :accepted , :refused  ]
      def accept 
          self.update(status: 1)
      end
      def refuse
          self.update(status: 2)
      end
      end
  end
  </code></pre>
  
  <p>And my routes:</p>
  
  <pre><code>root 'stat_page#home'
      get 'status' =&gt; 'job_apps#index'
      get 'stat_emp' =&gt; 'job_apps#empl'
      get 'login' =&gt; 'sessions#new'
      post 'login' =&gt; 'sessions#create'
      delete 'logout' =&gt; 'sessions#destroy'
      get 'logout' =&gt; 'sessions#destroy'
      get 'signup' =&gt; 'users#new'
      resources :users
  </code></pre>