So I am familiarising myself with both rails and of course rails 4.
So this is what I have at the bottom of my controller
def post_params
params.require(:post).permit(:title, :content, :category)
end
Which works fine, but what I would like to do is work out how to access those parameters individually either in the post_params method, or later in the controller.
Specifically I would like to change the :category value to lower case before making use of the parameter in creating the post (so that within the table all categories are in lowercase).
EDIT: perhaps a better phrasing to my question is, after permitting the parameters, how can i access and manipulate them afterwards..can I just use params[:title] as usual?
I have tried
params.require(:post).permit(:title, :content, :category)
params[:category].downcase
and
params.require(:post).permit(:title, :content)
params.require(:post).permit(:category).downcase
But I get undefined method 'downcase'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…