[Ruby on Rails (RoR)] Best practices about Rails Action Controller Overview
Best practices about Rails Action Controller Overview
In this guide you will learn what is the best practices about controllers work and how they fit into the request cycle in your application.
ActionDispatch::Request
Get url, path, fullpath from request.
1 | Full path with query string |
Pass arrays & objects via querystring
Rails has some great patterns for passing complex objects via querystring.
Arrays
1 | # QueryString: numbers[]=1&numbers[]=2&numbers[]=3 |
Objects
1 | # QueryString: user[id]=1&user[name]=Nathan |
Complex Objects
1 | # QueryString: users[][id]=1&users[][name]=Nathan&users[][id]=2&users[][name]=Emma |
Try It
You can try all this out yourself from a Rails console.
1 | # rails c |
See more to Pass arrays & objects via querystring the Rack/Rails way (Example)
More to see Ruby on Rails API - ActionDispatch::Request