Wednesday, 15 June 2011

routing - Why is Rails looking for an ID for my #collection# route? -



routing - Why is Rails looking for an ID for my #collection# route? -

i have...

routes.rb:

resources :standards collection :none end end

i next rake routes:

none_standards /standards/none(.:format) standards#none

i have next in standards_controller.rb:

def none end

so why "couldn't find standard without id" error @ /standards/none?

with better_errors, says:

(gem) activerecord-3.2.11/lib/active_record/relation/finder_methods.rb 305 306 ids = ids.flatten.compact.uniq 307 308 case ids.size 309 when 0 310 raise recordnotfound, "couldn't find #{@klass.name} without id" 311 when 1 312 result = find_one(ids.first) 313 expects_array ? [ result ] : result 314 else 315 find_some(ids) ... instance variables @table #<arel::table:0x007fc321207650 @name="standards", @engine=standard(id: integer, name: string, description: string, created_at: datetime, updated_at: datetime), @columns=nil, @aliases=[], @table_alias=nil, @primary_key=nil> @klass standard(id: integer, name: string, description: string, created_at: datetime, updated_at: datetime)

it's collection route not fellow member route, seems odd.

the problem declarative_authorization. had alter filter_resource_access (which assumes regular routes) filter_access_to :all (which covers routes) in standards_controller.rb.

ruby-on-rails routing

No comments:

Post a Comment