mdiaz00147 mdiaz00147 - 1 year ago 85
Ruby Question

Ruby on rails new object properties

i need to add to my user new objet some new properties that i will define when the form is submited by retrieve them from my database, but when i submited the new properties are nill and i dont know why

def create
plan = params[:user][:plan]
@plan_vars = Plan.find(plan)

@user =, :plan_id =>, :lessons => @plan_vars.lessons)
flash[:success] = "Usuario creado exitosamente"
redirect_to users_path
flash[:warning] = "Ooops... algo ha fallado :O #{@user.errors}"
redirect_to new_user_path

here is the user params

def user_params
params.require(:user).permit(:name, :email, :phone, :document, :password,

Answer Source

Here is what to do?

Do this:

@user =
@user.plan_id =
@user.lessons = @plan_vars.lessons

if nested form is used or @plan_vars returns array there results another type of error

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download