Replacing "." with "%2E" in Rails route -


i have rails controller action functions shown:

def rand     if !params.has_key?(:name)       rand_mymodel = mymodel.offset(rand(mymodel.count)).first       redirect_to "/crawl/" + rand_mymodel.name     end     @model = mymodel.where("name = ?", params[:name])[0] end 

with route:

get "crawl/:name" => "mymodel#rand" "crawl/" => "mymodel#rand" 

how can allow . appear in :name attribute replace %2e in route/url (similar how space replaced %20)

i want allow . appear in :name

did check respective guide?

by default :id parameter doesn’t accept dots – because dot used separator formatted routes. if need use dot within :id add constraint overrides – example :id => /[^/]+/ allows except slash.

the same true name:

get "crawl/:name" => "mymodel#rand", name: /[^\/]+/ 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -