No route matches (rails) -


i trying create simple link page in rails app doesnt seem work.even though have configured route posts index page gives me following error:

no route matches {:action=>"posts", :lat=>5, :controller=>"coordinates"} 

here's directory structure:

enter image description here

my routes.rb file

highwaypolice::application.routes.draw  resources:posts resources:coords resources:coordinates 'posts', to: 'posts#index'   end 

../app/views/coordinates/index.html.erb

 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>     <script type="text/javascript"       src="https://maps.googleapis.com/maps/api/js?key=aizasycthq7kv6r4-cilkpujzek5e-uzgbgdjku&sensor=false">     </script>     <script type = "text/javascript">      function initialize()      {console.log("click");     var mapoptions = {     center: new google.maps.latlng(-34.397, 150.644),     zoom: 8     };     var map = new google.maps.map(document.getelementbyid("map-canvas"),     mapoptions);   google.maps.event.addlistener(map, 'click', function(event) { console.log(event.latlng.k); }); var test = 3; $('#test').val(test); console.log(test); var lat = 3         var lon = 34         var parsed_data = {location: {lat: lat, lon: lon}}  }  </script>   <h1>coordinates#index</h1> <body onload = "initialize()"> <div id="map-canvas" style = "width:500px; height:500px"></div> <p>find me in app/views/coordinates/index.html.erb</p> <% @coordinates.each |coordinate| %> <p><%= coordinate.longitude %></p> <p><%= coordinate.lattitude %></p> <hr /> <% end %>  <%= link_to('save',{:action => 'post', :lat => 5}) %> 

posts_controller.rb

 class postscontroller < applicationcontroller     def index      end    end 

your current link trying post coordinates controller posts action.

if want post posts controller specified in routes controller try like

link_to "save", controller: :posts, action: :index, lat: 5 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -