Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8567833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:58:17+00:00 2026-06-11T17:58:17+00:00

On a search page I submit a query to the index action via a

  • 0

On a search page I submit a query to the index action via a form:

= form_tag reports_path, method: 'get' do
  = text_field_tag :query, params[:query]

I successfully pass it from reports#index view into #show view with:

= link_to params[:query] ? query_report_path(report.id, params[:query]) : report do

which is possible because of this route:

  resources :reports do
    get ':query', to: 'reports#show', on: :member, as: :query

but I’m trying to get same query back to #index action from a link in the reports#show view with:

= link_to 'Back', reports_path, query: @query

but it’s failing: :query = nil.

also tried:

= link_to 'Back', reports_path(query: @query, class: 'btn btn-small')

which doesnt’ work at all…

routing syntax has me tripped up…again! What’s the correct syntax? Is there a better way to do this? Why wouldn’t this trigger the same get reports#index with :query param that the initial form_tag is triggering?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:58:18+00:00Added an answer on June 11, 2026 at 5:58 pm

    I think your second try is close but your parentheses are wrong. Try passing the HTML options hash class: 'btn btn-small' as the third argument to link_to instead of as an argument to reports_path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to submit search query form & get search result without redirecting/reloading/refreshing on
How do I get a form to submit it's params in the url, such
I have a simple search page with this text input form <form name=assetInput action=assetResult.jsp
I have this configuration: A page containing a search field, at the submit in
I have a search page which uses a simple ajax request to get new
I have a search page like <div class=> <input id=search-input type=text class=input-medium search-query span4>
I've got a website where URLs are rewritten in this format: http://www.example.co.uk/module/page/query/ http://www.example.co.uk/index.php?m=module&p=page&q=query Which
Currently I've got a PHP page query.php with a form that presents a list
I have a search script written in jQuery. To submit a query a user
I'm trying to create a page with an AJAX style form. Where on submit,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.