Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in the Getting Started Guide? #11122

Closed
t-h- opened this issue Jun 26, 2013 · 4 comments · Fixed by #11127
Closed

Error in the Getting Started Guide? #11122

t-h- opened this issue Jun 26, 2013 · 4 comments · Fixed by #11127
Labels

Comments

@t-h-
Copy link

t-h- commented Jun 26, 2013

Hey there,

im just trying to learn RoR and followed the tutorial step by step so far. reaching 5.2:

"<%= form_for :post, url: posts_path do |f| %>
In this example, the posts_path helper is passed to the :url option. What Rails will do with this is that it will point the form to the create action of the current controller, the PostsController, and will send a POST request to that route."

I get an issue with this dubious posts_path, as it is not mentioned anywhere before in the tutorial and i have no clue how the syntax on the .erb files works. it tells me:

undefined local variable or method `posts_path' for #<# Class:0x3c297d8>:0x3402dc8>

somehow, i cant imagine me being the first one stumbling over this issue. on the other hand i have not that much clue what i am doing. so far, the tutorial has been perfect, but at this point it becomes a bit squishy.

regards

@pftg
Copy link
Contributor

pftg commented Jun 26, 2013

You have missed "For more information about routing, refer to Rails Routing from the Outside In." in the section 4.3.

But I agree with you there is no clue to add resources :posts to routes. Expected that you have added it before you start reading 5th section, without asking you to do that.

@davidcelis
Copy link
Contributor

From the guide:

5 Getting Up and Running

Now that you've seen how to create a controller, an action and a view, let's create something with a bit more substance.

In the Blog application, you will now create a new resource. A resource is the term used for a collection of similar objects, such as posts, people or animals. You can create, read, update and destroy items for a resource and these operations are referred to as CRUD operations.

Rails provides a resources method which can be used to declare a standard REST resource. Here's how config/routes.rb will look like.

Blog::Application.routes.draw do

  resources :posts

  root to: "welcome#index"
end

This occurs before the part about creating the form for a post.

@callmeed
Copy link

Actually, there is a clue to add resources :posts in the beginning of Section 5. The url value for that example is wrong. It's pointing to the correct spot.

@pastafari
Copy link

Would it be helpful to add something like this in section 5.2:

Remember, at this point, you have already added resources :posts to routes.rb which allows you to use the posts_path helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants