Note that there are some explanatory texts on larger screens.

plurals
  1. POTwo-page sign-up process in rails?
    text
    copied!<p>I'm attempting to create a rails app where a user will sign up, then immediately be directed to fill out a profile with more detailed information.</p> <p>I'm currently attempting this by having both a <code>users</code> and a <code>profile</code> model, with a <code>has_one/belongs_to</code> relationship between the two models. </p> <p>I'm having trouble with <code>create</code>ing the profile for the user. Tests fail with <code>undefined method</code>profiles' for #<code>when testing the creation, and using an automated profile builder called</code>sample_data.rake`:</p> <pre><code>namespace :db do desc "Fill database with sample data" task :populate =&gt; :environment do Rake::Task['db:reset'].invoke admin = User.create!(:name =&gt; "name name", :email =&gt; "fakename@fake.com", :password =&gt; "password", :password_confirmation =&gt; "password") admin.toggle!(:admin) 99.times do |n| name = Faker::Name.name email = Faker::Internet.email password = "password" User.create!(:name =&gt; name, :email =&gt; email, :password =&gt; password, :password_confirmation =&gt; password) end User.all.each do |user| User.profiles.create(:city =&gt; Faker::Address.city, :state =&gt; Faker::Address.us_state_abbr, ... ) end end end </code></pre> <p>Also fails on I'm having trouble with <code>create</code>ing the profile for the user. Tests fail with <code>undefined method 'profiles'</code></p> <p><code>profiles_controller.rb</code> is:</p> <pre><code>class ProfilesController &lt; ApplicationController before_filter :authenticate, :only =&gt; [:create, :edit] def create @profile = current_user.profiles.build(params[:profile]) if @profile.save flash[:success] = "Profile Created!" redirect_to root_path else render 'pages/home' end end def edit end end </code></pre> <p><code>profile.rb</code> is</p> <pre><code>class Profile &lt; ActiveRecord::Base attr_accessible :city, :state, ... belongs_to :user validates :city, :presence =&gt; true validates :state, :presence =&gt; true ... end </code></pre> <p>Can anyone see what I'm doing wrong? Is there a way to merge all the items I need under "users", validate the presence of all the required information, and have the signup process be two pages?</p> <p>Other suggestions for this?</p>
 

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