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

  • Home
  • SEARCH
  • 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 3842476
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:47:57+00:00 2026-05-19T15:47:57+00:00

I’m using ruby 1.9.2 and rails 3 and I think I’m having a moderately

  • 0

I’m using ruby 1.9.2 and rails 3 and I think I’m having a moderately simple problem with routing.

I have a model called AdvancedQuery.
Its controller is AdvancedQueriesController. Almost everything is done in the standard rails way except for the routing. I wanted to change the names of the URLs and I wanted to change a few other things (see below).

Here is the relevant portion of my routes.rb file

get   "advanced_query" => "advanced_queries#new", as: :new_advanced_query
post  "advanced_query(/:hash_value)(/:page)" => "advanced_queries#create",  as: :create_advanced_query
get   "advanced_query/:hash_value(/:page)"  => "advanced_queries#search",  as: :advanced_query_search

Here is the behavior that I expect when working with AdvancedQuery:

  1. User goes to http://localhost:3000/advanced_query (get request) and the browser invokes the “new” method in advanced_queries_controller. new.html.haml is rendered which shows the user a standard form to fill out.
  2. User then enters data into the search form and presses “Submit”
  3. “Submit” invokes the “create” method and creates an “AdvancedQuery” record in the database. The AdvancedQuery object has a 32-character hash associated with it that 1) identifies the query and 2) is used as part of the resulting URL (see step 4).
  4. The create method redirects to the “search” method where the AdvancedQuery object is used to search a 2nd model (called BusinessModel). The server then renders search.html.haml then shows the results of the AdvancedQuery and it re-renders the original form on the same page as the results in case the user wants to run a new search. The URL generated here is: http://localhost:3000/advanced_query/blah (where blah is a 32-character hash that’s specifically associated with the query).
  5. Now the user enters a new search term using the form from the web-page generated in Step 3. He presses “submit” and the “create” method should be invoked again (i.e. we re-do Steps 3 & 4). i.e. Create a new AdvancedQuery.

Here’s what happens in reality:

Steps 1 – 4 work as expected. Step 5 gives me a Routing Error "No route matches "/advanced_query"

Both the new.html.haml and the search.html.haml files render the same partial (called _form.html.haml).

So, if I look at _form.html.haml, I don’t really see anything wrong:

= form_for(@advanced_query, url: create_advanced_query_path) do |f|
  .actions
   # other generic form-related stuff

Here is the relevant portion of my controller

  def new
    @advanced_query  = AdvancedQuery.new
  end

  def create
    advanced_query  = AdvancedQueryBuilder.build_advanced_query_from_post(request, params, current_user)
    redirect_to(advanced_query_search_path(hash_value: advanced_query.hash_value))
  end

  def search
    return render :bad_request unless request.get?
    @advanced_query  = AdvancedQuery.find_by_hash_value_and_user_id(params[:hash_value], current_user.id)
    @results              = BusinessModel.advanced_search(@advanced_query)
  end

Any thoughts on what’s causing my routing error?

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-05-19T15:47:57+00:00Added an answer on May 19, 2026 at 3:47 pm

    It looks like your parentheses in routes.rb might not be matched correctly – do you mean to have

    post  "advanced_query(/:hash_value(/:page))" => "advanced_queries#create",  as: :create_advanced_query
    

    instead of

    post  "advanced_query(/:hash_value)(/:page)" => "advanced_queries#create",  as: :create_advanced_query
    

    ?

    Section 3 here: http://guides.rubyonrails.org/routing.html might be able to help; it’s not entirely clear what you’re looking to pass in.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't

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.