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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:10:09+00:00 2026-06-02T09:10:09+00:00

I have this filter in my Sinatra app: before ‘/:locale/*’ do # stuff… request.path_info

  • 0

I have this filter in my Sinatra app:

before '/:locale/*' do
  # stuff...
  request.path_info = params[:splat]
end

In other words, I want to just get the locale part of the URL and then let the app procede as if it wasn’t there. (Of course using the locale when rendering views.)

This works fine under Ruby 1.8.7 but breaks on >=1.9, because the splat is now an array with one item, instead of just a string. I had to use params[:splat].first to make it work.

My question is simply where this discrepancy comes from. Is it simply a Ruby 1.8 vs 1.9 thing? Or is Sinatra somehow involved?

Just want to be able to fix this kind of thing more easily in the future.

  • 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-02T09:10:11+00:00Added an answer on June 2, 2026 at 9:10 am

    Sinatra doc seems to indicate that params[:splat] can be either a string or an array, so you could do something like this to handle either case:

    request.path_info = [*params[:splat]].first
    

    Which I demonstrate here:

    $ cat splat.rb
    [ { :splat => [ "/foo" ] }, { :splat => "/foo" } ].each do |params|
        path_info = [*params[:splat]].first
        puts "#{path_info} (#{path_info.class})"
    end
    $ ruby1.8 splat.rb
    /foo (String)
    /foo (String)
    $ ruby1.9.1 splat.rb
    /foo (String)
    /foo (String)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this html structure <div class=top_menu> <ul> <li class=left><a href= class=family-filter>asdas</a></li> <li class=welcome>Welcome
I have some codes like this: cats = Category.objects.filter(is_featured=True) for cat in cats: entries
I have to filter a text file filter.tmp containing two types of lines, this
I have configured this filter for one of my log4net appenders (uses AdoNetAppender): <filter
I have this array of names (listedName) that I want to filter out and
I have this: foreach($_POST as $key => $value) { $data[$key] = filter($value); } filter();
I have this javascript: $('.foto').filter(function(index) { return index == Math.floor(Math.random() * 8) + 1;
I have this code: public static DataTable ExecutesAMAccountNameQuery(string sAMAccountName) { string filter = (&(objectCategory=person)(objectClass=user)(sAMAccountName=
right now, I have this code: var source = $('p').filter(function(){ return $(this).text().length > 300;})
OK let's say I have this .test { filter:DropShadow(Color=#000000, OffX=1, OffY=1); } Yes, it

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.