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 659977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:06:19+00:00 2026-05-13T23:06:19+00:00

I’m using static URLs in my RoR project. There is really no controller or

  • 0

I’m using static URLs in my RoR project. There is really no controller or action to map to so I tried putting in map.root "/static_page" or map.root "static_page" but I get errors. How do I just map to a path?

Edit: I am using a controller to serve up static pages, these aren’t html pages, but a static controller I’m using here: http://snafu.diarrhea.ch/blog/article/4-serving-static-content-with-rails

  • 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-13T23:06:19+00:00Added an answer on May 13, 2026 at 11:06 pm

    I do not think that map.root does what you want it to do.

    map.root looks like a named route because it is. But it’s a special named route for the routing of a url without a local path (eg: ‘http://www.example.com/‘). So it doesn’t need a path argument like standard named routes.

    It looks like you’re either unaware of what map.root does, or are trying to shoehorn the root mapping into your custom static controller.

    If it’s the former, just choose another name for your route to solve your problem.
    If it’s the later, all you really have to do is pass a specific path value. Place it above your catch all for static pages or else it will never match.

    map.root :controller => 'static', :path => "my_template.html"
    

    If you were trying to force a specific route to go to a specific static page, creating a file with that path descending from public will by pass routes entirely. So you don’t even need to write a route. (eg: http://www.example.com/whatever/static_pages automatically serves public/whatever/static_pages if it exists)

    However, if you want that file to contain erb/haml/etc, you want to use the method above, to route the request through your static controller. The question says that it doesn’t map to a controller/action, but by creating the static controller you do have a route and now an action for your named route. If for whatever reason the path doesn’t fit your controller logic, you can use the explicit_path action defined above to provide the desired path internally as a parameter with a route like this.

     map.static_page '/static_page', :controller => 'static',
      :path => "my template.html"
    

    P.S.: template_exist has been deprecated in Rails 2.3. So you will have to define it yourself if you upgrade.

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

Sidebar

Related Questions

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
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 am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.