Rails update attributes not validating

What i'm looking for is a way to either run white_list on the parameters in the params array (I don't know if accessing a specific param is even possible) or running it on the entity itself before it is saved.

currently the code is as follows: @post = Post.find(params[:id]) if @post.update_attributes(params[:post]) ...

This can be used along with record identification in Action Pack to allow, say, to render that instance using the companies/company partial instead of clients/client.end I cant seem to access the input received from the form independently (like params[:body] if I had a body text field in the form), and since update_attributes updates the attributes and also saves the data I'm stuck... Thanks, Ehud You can also do @post.attributes = params[:post].It updates the attributes without saving them to the database.If the record no longer exists in the database Active Record:: Record Not Found is raised. This method can be passed attribute names and an optional time argument.Otherwise, in addition to the in-place modification the method returns def with_optimistic_retry begin yield rescue Active Record:: Stale Object Error begin # Reload lock_version in particular. This method differs from its non-bang version in the sense that it passes through the attribute setter. If attribute names are passed, they are updated along with updated_at/on attributes.

Leave a Reply