why do we have use Model.new for def new and def create?
following the RailsTutorial book
(http://ruby.railstutorial.org/chapters/sign-up#sec-signup_form)
we have the following snippet:
def new
@user = User.new
end
def create
@user = User.new(user_params)
....
end
why do we need to recreate the model, if the user goes to /users/new def
new is called and @user variable is initialzed, but on post request (def
create), User.new is recalled, why is this? if we are going to create a
new user model on create then why create it in def new?
No comments:
Post a Comment