在我网站的用户简介科花了几天时间之后,我发现,建设——知名度并不奏效。
I don t know what is wrong,it doesn t make sense as it was working perfectly fine the other day. Now it doesn t create a row in the profiles table every time a new user is created.
这里,我的用户控制员制定了行动守则:
def create
@user = User.new(params[:user])
respond_to do |format|
if @user.save
@user.build_profile.save #same as Profile.new(:user_id => @user.id)
login @user
UserMailer.join_confirmation(@user).deliver
format.js { render :js => "window.location = #{root_path} " }
# flash[:notice] = "Welcome!"
else
format.js { render :form_errors }
end
end
end
Users model:
class User < ActiveRecord::Base
has_one :profile, :autosave => true
accepts_nested_attributes_for :profile
# Setter and getter methods
attr_accessor :password # virtual password attribute
# A list of white list of attributes accessible by users in forms
attr_accessible :email, :username, :password, :password_confirmation
简介模式:
class Profile < ActiveRecord::Base
belongs_to :user
# attr_accessor :password
attr_accessible :first_name, :last_name, :gender, :motd, :birthday,
:marital_status, :sexual_preference, :location, :country, :ethnicity,
:about_me, :height, :eye_colour, :body_type, :likes, :dislikes, :drugs,
:alcohol, :cigarettes, :bad_habits, :food, :music, :television, :book,
:animal, :place, :possession, :sport
孟加拉方法错误:
NameError (undefined local variable or method `build_profile for #<UsersController:0x00000101d63510>):
app/controllers/users_controller.rb:16:in `block in create
app/controllers/users_controller.rb:14:in `create
这实际上是一种空想,因为它正在为此而努力,并且已经停止了。
I would really appreciate some help with this Kind regards
<>Update>
光谱错误:
Failures:
1) UsersController JOIN create success should create a user
Failure/Error: post :create, :user => @user
NoMethodError:
undefined method `ethnicity for #<Profile:0x0000010367cab0>
# ./app/controllers/users_controller.rb:16:in `block in create
# ./app/controllers/users_controller.rb:14:in `create
# ./spec/controllers/users_controller_spec.rb:96:in `block (5 levels) in <top (required)>
# ./spec/controllers/users_controller_spec.rb:95:in `block (4 levels) in <top (required)>
Finished in 2.75 seconds
47 examples, 1 failure, 1 pending
Failed examples:
rspec ./spec/controllers/users_controller_spec.rb:94 # UsersController JOIN create success should create a user
Strange! 我做了检查,我的 d布和旁听的 list名单都存在这种特征,因此我很aff。
我投下并重新移民,但还没有uck。