On Tuesday, April 19, 2011 12:59:29 PM UTC-6, Ruby-Forum.com User wrote:
>
> Hello! Im developing my first rails application =) I have such a code in
> my routes.rb:
>
> >match 'category/:category' => "articles#index", :as =>
> >'articles_from_category'
>
> It's obvious that rails will load anything that comes after /articles/,
> even a mess route like /articles/dsfjsdfsd. What i want to do is to make
> rails
> know that there is only a few path i want it to load (such
> /articles/science ) and for a mess routes just render 404 page . Im
> trying
> to do that using constraints like this:
>
> >match 'category/:category' => "articles#index", :as =>
> >'articles_from_category', :constraints => { :category =>
> >/"technology"|"science"|"gadgets"|"cosmos"/ }
>
> but it doesn't work. any ideas? I'd really appreciate any help! May be i
> doesn't need to use constraints at all?
>

Try removing the double quotes from your constraint's regular expression:

match 'category/:category' => "articles#index",
  :as => 'articles_from_category',
  :constraints => { :category =>/technology|science|gadgets|cosmos/ }
 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to