Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSarah Eichenstein
7,488 PointsFirst argument in form cannot contain nil or be empty
I followed along step by step with the teacher and for some reason I'm getting an error when I try and load the server. Even when I copy and paste the teacher's code and use that - I get the same error. This is the code:
<%= form_for(@page) do |f| %>
<div class="field">
<%= f.text_field :title %>
</div>
<% end %>
I have that in /app/views/pages/new.html.erb.
2 Answers
Sarah Eichenstein
7,488 PointsOh ok. I see my mistake. I forgot to put the "def new" before the last end. Thanks for your help!
Sarah Eichenstein
7,488 Pointsclass PagesController < ApplicationController
def index
@pages = Page.all
end
def show
@page = Page.find(params[:id])
end
end
def new
@page = Page.new
end
This is the code I have in pages_controller.rb
Jay McGavren
Treehouse TeacherJay McGavren
Treehouse TeacherIt probably means that
@page
is set tonil
. Something may be wrong in your controller. Can you post the code for thePagesController
'snew
method?