I'm trying to use Rails with Angularjs. Angular will do all the client side work while Rails controllers suppose to handle requests to list and modify information (in Database).
I have a simple template in views/layouts/application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>SomeApp</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= stylesheet_link_tag "vendors", :media => "all" %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="wrapper" ng-app="app" ng-controller="AppCtrl">
<div ng-controller="SomeApprCtrl">
<%= render 'header' %>
<div ng-view=""></div>
<%= render 'footer' %>
</div>
</div><!-- End on wrapper -->
<%= javascript_include_tag "application" %>
</body>
</html>
This template does everything i need to start Angular. But i need to put something in Rails routes. I need to define controller and action. Say something like this:
root :to => 'main#index'
And this mean that I need to define controller Main with only one empty method index and totally empty template file in views/main/index.html. How can i avoid appearance of this empty useless files?
I was thinking of using root :to => 'application#index' and define empty index method in ApplicationController but since this controller is basic for inheritance to all other controllers i don't want them to have any crap. Also this approach does not solves problem with empty index.html template
While it is empty the controller is actually handling a lot by convention. It automatically displays the index.html.erb view, and since the layout hasn't been specified it wraps it in the application.html.erb layout.
So while the file may be sparse there's a lot going on behind the scenes.