I've got a route that looks like this:
get ':q', to: 'foo#bar'
and I can access it inside my foo_controller through:
params[:q].
Is it somehow possible to nest the params-hash so that it can access it through:
params[:namespace][:q]
yes, its possible and very easy to do so. 1. Declare the routes properly for the nested resources. refer to the link1 below.
allow nested attributes in the strong parameters. like this:
params.require(:abc).permit(:name, :email, custome_attribute: { :id, :_delete, :name})
Remember :id and :_delete is neceesary if you want to delete the nested resources. Now construct your form using rails form builder. follow the 2nd link below.
Please go through the following tutorial:
http://guides.rubyonrails.org/routing.html#nested-resources
http://guides.rubyonrails.org/form_helpers.html#nested-forms
get :qdoes is creates a route that matches the path/q.[foo][bar]bazwhich Rack then deserializes into nested hashes. You can achieve this withfields_forbut you should really get a grasp of the fundamentals first.