I was following the Ruby on Rails tutorial by Michael Hartl, and I used the template there to create a contacts page for my application. However, I would like to add a contacts page that has a form method. I use the same Static Pages Controller as Hartl with the same pages. I need to get my contacts page to work.
<h1>Contact us</h1>
<%= form_for @page, url: static_pages_contact_path do |f| %>
<p>
<%= f.label :title %>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :email %>
<%= f.text_area :email %>
</p>
<%= f.submit 'Send message' %>
<% end %>
The error message I get involves first row can't be nil or something like that. For the record, here is my static-pages-controller.
class StaticPagesController < ApplicationController
def show
@page = StaticPage.find(params[:id])
end
def new
@page = Page.new
end
def create
@page = Page.find(params[:page])
end
end
Running rake routes shows this
Prefix Verb URI Pattern Controller#Action
users_new GET /users/new(.:format) users#new
favorite_game PUT /games/:id/favorite(.:format) games#favorite
games GET /games(.:format) games#index
POST /games(.:format) games#create
new_game GET /games/new(.:format) games#new
edit_game GET /games/:id/edit(.:format) games#edit
game GET /games/:id(.:format) games#show
PATCH /games/:id(.:format) games#update
PUT /games/:id(.:format) games#update
DELETE /games/:id(.:format) games#destroy
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
sessions POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
session DELETE /sessions/:id(.:format) sessions#destroy
users_favorites GET /users/favorites(.:format) users#favorites
static_pages_about GET /static_pages/about(.:format) static_pages#about
static_pages_contact GET /static_pages/contact(.:format) static_pages#contact
static_pages_help GET /static_pages/help(.:format) static_pages#help
signup GET /signup(.:format) users#new
signin GET /signin(.:format) sessions#new
signout DELETE /signout(.:format) sessions#destroy
I think that's all the information I need.