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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -