Question

I have a three part user signup that work with two separate models: User, and Customer Info. There's a user signup that I submit remotely, and it goes to the next part of the form. I want to be able to use the current_user variable when I submit the Customer Info row. The following code works when I test without remote, but it just doesn't even create the row at all when I do it with the remote. Is there another variable I can use in lieu of this variable? Or is there a better way of accomplishing this?

  def create
    @customer_info = CustomerInfo.new(params[:customer_info].merge(:user_id => current_user.id))

    respond_to do |format|
      if @customer_info.save
        format.html { redirect_to tasks_url, notice: 'Customer info was successfully created.' }
        format.json { render json: tasks_url, status: :created, location: @customer_info }
      else
        format.html { render action: "new" }
        format.json { render json: @customer_info.errors, status: :unprocessable_entity }
      end
    end
  end
Was it helpful?

Solution

Turns out it was a devise config situation. I wasn't allowing users to be unconfirmed for any amount of time, so "curent_user" was staying empty even after they signed up. I added config.allow_unconfirmed_access_for = 2.days and restarted the server and that worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top