httprequest - Get referrer URL with parameters in Rails -
i have site basic rails scaffold, when user deletes record default action redirect home page. return list user looking at. right i'm using request.referrer
technically getting referral url parameters not included...
in rails logs can see "started /books/book_preview?name=hunger+games"
request.referrer
shows "https://x.x.x.x/books"
have tried .original_url
, .original_fullpath
return path of current page record "/books/hungergames". tried uri(request.referrer).query
@ least parameters threw error.
previous path parameters like: /books/books_preview?name=hunger+games
also list remote partial rendered through js. can't see url in browser url bar when highlight on or in rails logs. doesn't show in request when looked through using request.inspect
.
thanks in advance help! have been stuck on day!
you're not getting query string
url, according this answer (& docs), need:
request.fullpath #-> book_preview?name=hunger+games
--
as aside, if you're using lists page, should okay. however, if you're wanting pull specific book
records, you'd better using member
route:
#config/routes.rb scope "/books" resources :book_preview, only: :show, param: :name #-> url.com/books/book_preview/:name end
this give ability return specific object book, negating need hack request path etc.
Comments
Post a Comment