I have Rails form with textarea. User puts text spltted by comma, then submit to server, where data validates, splits to array and writes to postgres database.
But there is null array in callback before_validation. Here's it:
class UsersController < ApplicationController
def update
@user = User.find(params[:id])
if @user.update(user_params)
# show profile
end
end
private
def user_params
params.require(:user).permit(
:nickname,
:password,
{tags:[]})
end
and
class User < ActiveRecord::Base
before_validation :tags_must_be_list
def tags_must_be_list
p tags ####### here is tags is empty [], but need to be text
errors.add(:tags, "is not list")
end
What's wrong?