Ruby on Rails – Anatomy of a Request object

Display current url without base url

<%= request.request_uri %> / <%= request.path%>
eg: /vinova/development/web_and_iphone_apps

Display previous url with base url

<%= request.referer %>
eg: http://www.vinova.sg/development/web_and_iphone_apps

Display base url

<%= request.env[‘HTTP_HOST’]%>
eg: www.vinova.sg

Display protocol

<%= request.env[‘SERVER_PROTOCOL’]%>
eg: HTTP/1.1

Full url

<%= request.url%>
eg: http://www.vinova.sg/development/web_and_iphone_apps

Display how many parameters found in current url

<%= request.query_parameters.size %>

url eg: www.vinova.sg/index.html?key=3&d=4
answer: 2 => (2 parameters)

Display controller name from current url

<%= request.path_parameters[‘controller’] %>
eg: contents

Display action name from current url

<%= request.path_parameters[‘action’] %>
eg: login

Everything inside a request

<%= request.inspect%>

vinova

Recent Posts

Top 8 Government Grants in Singapore for Startups in 2024

Starting a new business can be a daunting task, especially when it comes to securing…

17 hours ago

TOP 30+ Web Development Terms Beginners Need to Know

Understanding the language of web development is important for anyone working in the tech field.…

2 days ago

Top 7 Rapid Mobile App Development Tools and Platforms

The mobile app market is exploding, with an estimated 128 billion downloads in 2020 alone.…

3 days ago

Top 15 Mobile Application Development Mistakes to Avoid in 2024

A shocking statistic: Over 25% of downloaded apps are used only once before being deleted,…

4 days ago

Top 10 Most Popular Cross-Platform App Frameworks in 2024

Mobile apps have become an essential component of business success. However, developing native apps for…

5 days ago

TOP 5 Must-Try Free Meditation Apps in 2024

The meditation app market is booming, with the best free meditation apps having a projected…

6 days ago