Reputation: 383
Is it possible in Rails 4 to create a scope of constraints as described in here?
scope format: true, constraints: { format: 'json' } do
get '/bar' => "bar#index_with_json"
end
The error I'm getting is
NoMethodError (undefined method 'source' for "json":String):
config/routes.rb:17:in `block (2 levels) in <top (required)>'
config/routes.rb:16:in `block in <top (required)>'
config/routes.rb:1:in `<top (required)>'
Upvotes: 2
Views: 2507
Reputation: 383
Found it, format type must be in slashes:
scope format: true, constraints: { format: /json/ } do
get '/bar' => "bar#index_with_json"
end
Upvotes: 2