Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

I’m adding stuff to params[:record] but ActiveScaffold doesn’t use it. Why?

0
Posted

I’m adding stuff to params[:record] but ActiveScaffold doesn’t use it. Why?

0

ActiveScaffold doesn’t just apply the whole params[:record] hash. Instead, it whitelists fields it expects from the form. Which is to say, if ActiveScaffold didn’t know that role_id was supposed to be on the form, it will ignore the params[:record][:role_id] entry. If it didn’t work this way, then URL hackers could submit extra data and do all kinds of fun things including privilege escalation. If you need to apply your own data to the record before its gets saved, what you should do instead is define before_create_save(record) or before_update_save(record) on your controller. ActiveScaffold will check for these methods and pass them the record object so you can do common things like attach the current user as the record’s owner.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123