ruby - Rails location of model with two words -
i doing api backend in ruby on rails.
i have model, call testmodel
. when user creates new record of method, want return location
header containing url of newly created object (i.e. user can access using get), try
render json: @test_model, status: :created, location: @test_model
unfortunately, rails can't give me location, because seems try call method test_model_url
, rails seems interpret url object model
subobject of item test
.
how can correctly?
this has nothing model naming, more how ruby on rails work convention. cf. rails guide on routing (especially part 2.3)
each of these helpers has corresponding _url helper (such photos_url) returns same path prefixed current host, port , path prefix.
-> have setup routes correctly, _url , _path helpers work.
you should stick rails naming conventions, model should named testmodel
instead of testmodel
.
Comments
Post a Comment