Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

request.fullpath gives the fullpath plus any parameter passed, such as

/page?param1=value&param2&value

How can I get just the page with no params? Like

/page

Thank you.

question from:https://stackoverflow.com/questions/5265943/request-fullpath-with-no-parameters

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
359 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use path instead of fullpath.

Although not documented, request.path worked for me. I usually use my plugin rails_web_console for playing with the request object.

Update:

As noticed by turboladen, "[ActionDispatch::Request][2] inherits from [Rack::Request?][3]?, where request.path is defined".

path is not documented there, but the source displays script_name + path_info.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...