reactjs - Rails custom route does not map correctly -


i´m making ajax request controller having problem routing. request: (using react.js)

$.ajax({             type: 'get',             url: 'allrooms',             datatype: 'json',             success:function(data){                 this.setstate({data:data});             }.bind(this)         }); 

i´ve put in routes.rb:

  'allrooms', to: 'rooms#allrooms' 

now, allrooms method defined inside rooms_controller

however, request gets url when trigged: http://localhost:3000/houses/allrooms

the call made show-view of house-controller.

why not request route rooms-controller? (i´ve restarted rails server multiple times)

try changing js code as:

$.ajax({   type: 'get',   url: '/allrooms',   datatype: 'json',   success:function(data){     this.setstate({data:data});   }.bind(this) }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -