Rails 4 Strong Parameters with delegate -


i trying receive parameters being celeb model , delegate right ones user:

class celeb < activerecord::base    has_one :user, as: :role, dependent: :destroy    delegate :name, :username, :email, :password, :password_confirmation, :name=, :username=, :email=, :password=, :password_confirmation=, to: :user end 

in controller:

def create     @celeb = mount_celeb()     @celeb.assign_attributes celeb_params     ...    end  def celeb_params     params.require(:celeb).permit(:email, :username, :name, :password, :password_confirmation) end  def mount_celeb     celeb = celeb.new     celeb.build_user     celeb   end 

but associated user remains empty no fields assigned. there way achieve using strong parameters?

the code in question works expected. problem debugging mode( byebug ) somehow not reflecting last changes.

the reason did way because creating api it's better idea abstract nested attributes documentation( bad ask clients send "user_attributes" in every request)


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -