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 trial

Ruby

Kian Chakamian
Kian Chakamian
15,410 Points

Problems with my create view file

I have been getting this same syntax error reading: undefined method `grouponepages_path' for #<#<Class:0x007f8f0e932d68>:0x007f8f0e9c2cd8>

This is my new.html.erb:

<%= form_for (@postings1314) do |f| %>
  <div>
    <%=@postings1314.label :firstName%>
    <%=@postings1314.text_field :firstName%>
  </div>

  <div>
    <%=@postings1314.label :lastName%>
    <%=@postings1314.text_field :lastName%>
  </div>

  <div>
    <%=@postings1314.label :age%>
    <%=@postings1314.text_field :age%>
  </div>

  <div>
    <%=@postings1314.label :bio%>
    <%=@postings1314.text_field :bio%>
  </div>

  <div>
    <%= @postings1314.submit %>
  </div>
<%end%>

This is my grouponepostings_controller.rb:

class GrouponepostingsController < ApplicationController
  def index
    @postings1314 = Grouponepage.all
  end
  def show
    @posting1314singular = Grouponepage.find(params[:id])
  end
  def new
    @postings1314 = Grouponepage.new
  end
end

This is my routes.rb:

Rails.application.routes.draw do
  get "/", to: "pages#index"
  get "/grouponepostings", to:"grouponepostings#index"
  get "/grouponepostings/new", to:"grouponepostings#new"
  post "/grouponepostings", to: "grouponepostings#create"
  get "/grouponepostings/:id", to:"grouponepostings#show"

1 Answer

May I ask how you're using this path? get "/grouponepostings/new", to:"grouponepostings#new" It seems like the /new is the problem.

Kian Chakamian
Kian Chakamian
15,410 Points

What do you mean by "using the path". I am just using this to create the new Grouponepage and render new.html.ern.