English 中文(简体)
铁路3号公路
原标题:Rails 3 Route Wildcards

我目前正在建立铁路3号申请的路线,如果有人能向我指明正确方向,我将不胜感激。

基本上,我正在建立一些路线,为一些有条不紊的退学现象提供数据,并且希望能够有下列路线:

/vehicles/trims/01299999
/vehicles/trims/02299999

1 0299999和022999999999是两种不同的参数(在这种情况下,请说的是1 0299999载荷:车辆进入准绳,229999999是:油类。 我知道,我可以确保他们通过使用限制,前往正确的控制者行动,装载正确的武器。

然而,造成这一复杂情况的原因是,我能够按任何顺序安排在导游中指明一个以上选择,例如:

/vehicles/trims/01299999/02299999

/vehicles/trims/02299999/01299999

and these would load the c或rect params based on the structure of the id number (so if it starts with 012 it should always be :vehicle_make and if it starts 022 it should always be :fuel_type. How can I do this?

As a side note, it would be great if anyone could indicate how to constrain the id column f或 my models, so that when a vehicle make is created, its id should always start 012 and so on.

Thanks f或 any assistance!

最佳回答

一条通过<条码>/分离的路边野生卡收集到任何数量的URL元素,并照此办理:

match  /vehicles/trims/*trims  =>  vehicles#trims 
# change  vehicles#trims  to match your controller and action names

You say:

As a side note, it would be great if anyone could indicate how to constrain the id column for my models, so that when a vehicle make is created, its id should always start 012 and so on.

通常,主要关键因素不应有意义。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签