in this example what if i didn't have a values for science, physics and gravity but had to get it from form what field would i use? my guess any of the 3 variables can be substituted with params[:id] ?
Again, unfortunately, I have little idea of exactly what you are
asking. If the form is generated by
form_for @category
then 'name' would be one of the fields expected to be in the form, so
you should be able to do
Category.create!(params[:category])
though it would be more usual to use new and save and then check the
return value of save in case there were validation errors.
params[:category] is identical to category_params. As an old hand I
don't necessarily make use of later useful syntactical goodies in
rails. Look at the params structure in the controller and you will
see how the hash is organised. In fact I am not sure whether I like
using category_params as it is not obvious exactly what is being
referred to, whereas params[:category] can only refer to the category
hash within the params hash.