Note that there are some explanatory texts on larger screens.

plurals
  1. POCollection Select with Devise (Rails 3.2)
    primarykey
    data
    text
    <p>I am working on an application where we have <code>users</code> and <code>projects</code>. Each user can manage a project. In any case, I'd like the users to define / choose their project at <code>sign up</code>. Users and projects are linked with a <code>has many through</code> association.</p> <p>I've added this code to the sign up form using <code>form_for</code>.</p> <pre><code>&lt;%= f.collection_select :project_ids, @projects, :id, :project_name, {}, { :multiple =&gt; false } %&gt; </code></pre> <p><strong>In Development:</strong> It works perfectly!</p> <p><strong>In Production:</strong> It breaks, I get "We're sorry, but something went wrong." from Heroku and the user is not created. </p> <p>The logs don't give a reason why this fails.</p> <pre><code>2013-11-27T20:40:11.087603+00:00 app[web.1]: Started POST "/users" for 66.44.22.241 at 2013-11-27 20:40:11 +0000 2013-11-27T20:40:13.443773+00:00 app[web.1]: 2013-11-27T20:40:13.443773+00:00 app[web.1]: Sent mail to tests@email.com (894ms) 2013-11-27T20:40:13.935915+00:00 app[web.1]: Started GET "/" for 66.44.22.241 at 2013-11-27 20:40:13 +0000 </code></pre> <p>When I remove the association attribute,sign in works and the log looks the same (to me, at least).</p> <pre><code>2013-11-27T20:45:21.122286+00:00 app[web.1]: Started POST "/users" for 66.44.22.241 at 2013-11-27 20:45:21 +0000 2013-11-27T20:45:22.402149+00:00 app[web.1]: 2013-11-27T20:45:22.402149+00:00 app[web.1]: Sent mail to tests@email.com (714ms) 2013-11-27T20:45:23.116820+00:00 app[web.1]: Started GET "/" for 66.44.22.241 at 2013-11-27 20:45:23 +0000 </code></pre> <p>My devise override: </p> <pre><code>def create @user = User.new(params[:user]) resource = @user if resource.save yield resource if block_given? if resource.active_for_authentication? flash[:notice] = "Signed up successsfully." sign_up(resource_name, resource) respond_with resource, :location =&gt; after_sign_up_path_for(resource) else flash[:notice] = "Signed up successsfully." expire_data_after_sign_in! respond_with resource, :location =&gt; after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource respond_with resource end end </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