Reputation: 15
I'm learning to develop a Rails application by following this book: http://ruby.railstutorial.org Currently I am at Chapter 6.
It all went fine untill I wanted to check out the app using the 'rails s' command. After running the command I got the following error:
'default_controller_and_action': missing :action (ArgumentError)
I had this problem earlier and solved it by correcting a mistake in 'routes.rb'. But I am not able to solve it this time ;(
routes.rb
SampleApp::Application.routes.draw do
get "users/new"
root to: 'static_pages#home'
match '/signup', to: 'users#new'
match '/home', to: 'static_pages#home'
match '/help', to: 'static_pages#help'
match '/about', to: 'static_pages#about'
match '/contact', to: 'static_pages#'
end
application.html.erb
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
</div>
</body>
</html>
_header.html.erb
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<%= link_to "sample app", root_path, id: "logo" %>
<nav>
<ul class="nav pull-right">
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Help", help_path %></li>
<li><%= link_to "Sign in", '#' %></li>
</ul>
</nav>
</div>
</div>
</header>
_footer.html.erb
<footer class="footer">
<nav>
<ul>
<li><%= link_to "About", about_path %></li>
<li><%= link_to "Contact", contact_path %></li>
<li><a href="#/">News</a></li>
</ul>
</nav>
</footer>
I hope that someone can help me solve this problem! :)
Thanks in advance!
Upvotes: 1
Views: 50
Reputation: 8986
match '/contact', to: 'static_pages#'
is missing an action.
It has the form 'controller#action'
. In this case you only provided the controller, but is missing the action name.
If in this part of the tutorial you still haven't created an action for contact, you can either comment this line out until you create it, or create a controller for it now.
In the first case, the code would be
# match '/contact', to: 'static_pages#'
In the second case, it would be necessary to insert
# app/controllers/static_pages_controller.rb
...
def contact
end
And create a layout at /app/views/static_pages/contact.html.erb
Upvotes: 4