ruby on rails - Wicked Gem with cocoon gem and devise user model -
so have user
model generated devise
, , using wicked
gem give me multiform option on taking more data user , storing in user model.
everything working fine know i'm trying add model user has many degree. using cocoon gem allow me add degrees
. able go multiform page , enter degree information , add many more degrees user, when submit form error;
param missing or value empty: user
everything else gets saved can view user , rest of fields entered non of degrees.
user model:
has_many :degrees accepts_nested_attributes_for :degrees, reject_if: :all_blank, allow_destroy: true
degree model:
belongs_to :user
user_steps_controller (this wicked gem controller):
class userstepscontroller < applicationcontroller include wicked::wizard steps :personal, :avatar_and_about_yourself, :social, :education def show @user = current_user render_wizard end def update @user = current_user @user.update_attributes(user_params) render_wizard @user end private def user_params params.require(:user).permit(:name, :middlename, :lastname, :avatar, :aboutme, :twitterlink, :githublink, :stackoverflowlink, :mediumlink, :dribblerlink, degrees_attributes: [:id, :degreename, :university, :level, :done, :_destroy]) end end
registration controller (for devise):
class users::registrationscontroller < devise::registrationscontroller # before_filter :configure_sign_up_params, only: [:create] # before_filter :configure_account_update_params, only: [:update] # /resource/sign_up def new super end # post /resource def create super end # put /resource def update super end protected # path used after sign up. def after_sign_up_path_for(resource) user_steps_path end # path used after sign inactive accounts. def after_inactive_sign_up_path_for(resource) user_steps_path end def sign_up_params params.require(:user).permit(:email, :password, :password_confirmation, :name, :middlename, :lastname, :avatar, :aboutme, :twitterlink, :githublink, :stackoverflowlink, :mediumlink, :dribblerlink, degrees_attributes: [:id, :degreename, :university, :level, :done, :_destroy]) end end
im getting error in user_steps_controller:
actioncontroller::parametermissing in userstepscontroller#update param missing or value empty: user
and error within line:
def user_params params.require(:user).permit(:name, :middlename, :lastname, :avatar, :aboutme, :twitterlink, :githublink, :stackoverflowlink, :mediumlink, :dribblerlink, degrees_attributes: [:id, :degreename, :university, :level, :done, :_destroy]) end
also how go , view entered fields, example if wanted view user name is:
<%= @user.name %>
but how show each degree? loop?
<% @users.degree.each |degree| %>
terminal log:
started patch "/user_steps/education" ::1 @ 2016-02-09 11:23:29 +0000 processing userstepscontroller#update html parameters: {"utf8"=>"✓", "authenticity_token"=>"exn7ts6xpvk8vkc7q6ucnlejjwlutkmow41t0qsdqxcrpj0vihrb/6xifpp/o+cxkr47f+6lxuy5ljxlcobkzq==", "commit"=>"update user", "id"=>"education"} user load (0.2ms) select "users".* "users" "users"."id" = ? order "users"."id" asc limit 1 [["id", 16]] completed 400 bad request in 2ms (activerecord: 0.2ms) actioncontroller::parametermissing (param missing or value empty: user): app/controllers/user_steps_controller.rb:20:in `user_params' app/controllers/user_steps_controller.rb:13:in `update'
this long comment, expect update it.
the problem have form submission not include user
params:
parameters: {"utf8"=>"✓", "authenticity_token"=>"exn7ts6xpvk8vkc7q6ucnlejjwlutkmow41t0qsdqxcrpj0vihrb/6xifpp/o+cxkr47f+6lxuy5ljxlcobkzq==", "commit"=>"update user", "id"=>"education"}
this might wicked
, judging form spurious use of registrationscontroller
, i'd imagine formatting etc:
--
if you're updating current_user
, should not invoking registrations
controller. registrations -- should using users
controller:
#config/routes.rb resource :user_steps, path: "user", only: [:show, :update] #-> url.com/user (singular resource) #app/controllers/user_steps_controller.rb class userstepscontroller < applicationcontroller def show end def update @user = current_user.update user_params render_wizard @user end private def user_params params.require(:user).permit(:name, :middlename, :lastname, :avatar, :aboutme, :twitterlink, :githublink, :stackoverflowlink, :mediumlink, :dribblerlink, degrees_attributes: [:id, :degreename, :university, :level, :done, :_destroy]) end end
this controller; need @ how form
being rendered & passed.
if you're sending data above code, you'll want pull form
html , show how wicked
working it.
you need looking in app/views/users/show.html.erb
form display, not /app/views/registrations
Comments
Post a Comment