-1

I have a question about the 5th video 'Routing into darkness'.
At about 3 minutes 44 seconds Greg is describing how to set up a link_to using a custom route. A line appears saying "tweets_path wouldn't work".
I'd like to know WHY tweets_path wouldn't work. I'm hoping knowing why will help demystify Rails some more. At the moment that line seems a bit arbitrary and I'd like to make sense of it.

EDIT

Sorry, for some reason I was thinking you'd need to see the video. Here's the relevant code:
In his routes.rb file:

get '/all' => 'tweets#index'

And in a view, somewhere:

<%= link_to "All Tweets", ?? %> # tweets_path wouldn't work
moosefetcher
  • 1,841
  • 2
  • 23
  • 39
  • 1
    Please do consider adding few lines of coding. that will clear the question ? – Ajay Jan 13 '15 at 17:22
  • Very difficult to get the context out of what your question is? Why did Greg say `"tweets_path wouldn't work`? – PericlesTheo Jan 13 '15 at 17:23
  • This is a long shot but what Greg might be referring to is you need to use an absolute URI when creating a redirect instead of just the path. – PericlesTheo Jan 13 '15 at 17:25

1 Answers1

0

tweets_path won't work here because there isn't a route called 'tweets_path' in his routes.rb file. The only routes that he has (at least that we can see) is the '/all' route, which goes to the tweets controller and index action. If Greg put resources :tweets in his routes.rb file, then tweets_path would work. Also, if you have the code get '/all' => 'tweets#index' (i.e. without as: 'all_tweets'), then all_path will work. With as: 'all_tweets', then only all_tweets_path will work

Ryan K
  • 3,985
  • 4
  • 39
  • 42
  • Thanks for taking the time and (I assume) re-watching the video. I've added the code, above. Your answer sounds sensible to me. I'm finding it hard to remember which routes Rails generates from which syntax. I really wish there were more 1-1 correlations between things. Slowly getting there. – moosefetcher Jan 14 '15 at 14:18