Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
#3: Post edited by user avatar trichoplax‭ · 2024-06-05T16:38:47Z (6 months ago)
Include information about the view
  • The function `comment_thread_path` is created automatically by Rails, based on the information provided in `config/routes.rb`.
  • See [The Ruby on Rails guide to routing](https://guides.rubyonrails.org/routing.html) for further details.
  • Specifically, line 236 of `config/routes.rb` says (enclosing scope included for context):
  • ```ruby
  • scope 'comments' do
  • ...
  • get 'thread/:id', to: 'comments#thread', as: :comment_thread
  • ...
  • end
  • ```
  • This responds to a GET request on the route `/comments/thread/:id` by calling the `thread` method of the `CommentsController` (signified by `comments#thread`).
  • The `as: comment_thread` overrides the default name that Rails would otherwise use in its automatically generated helper functions (otherwise it would use the default `comments_thread` - note the pluralisation). Now `comment_thread_path` and `comment_thread_url` are available, each a function taking a thread id as argument:
  • - Calling `comment_thread_path(123)` returns `/comments/thread/123`
  • - Calling `comment_thread_url(123)` returns the same thing but including the domain at the beginning, such as `example.com/comments/thread/123`.
  • The function `comment_thread_path` is created automatically by Rails, based on the information provided in `config/routes.rb`.
  • See [Rails Routing from the Outside In](https://guides.rubyonrails.org/routing.html) for further details.
  • Specifically, line 236 of `config/routes.rb` says (enclosing scope included for context):
  • ```ruby
  • scope 'comments' do
  • ...
  • get 'thread/:id', to: 'comments#thread', as: :comment_thread
  • ...
  • end
  • ```
  • This responds to a GET request on the route `/comments/thread/:id` by:
  • - First calling the `thread` method of the `CommentsController`
  • - Then rendering the `app/views/comments/thread.html.erb` view.
  • See [Action Controller Overview](https://guides.rubyonrails.org/action_controller_overview.html) for further details.
  • The `comments#thread` in the routes file determines both:
  • - Which controller and method to call (being in the format `controller#method`)
  • - Which view to render and where to find it (being in the format `directory#viewfile`)
  • The optional `as: comment_thread` overrides the default name that Rails would otherwise use in its automatically generated helper functions (otherwise it would use the default `comments_thread` - note the pluralisation). Now `comment_thread_path` and `comment_thread_url` are available, each a function taking a thread id as argument:
  • - Calling `comment_thread_path(123)` returns `/comments/thread/123`
  • - Calling `comment_thread_url(123)` returns the same thing but including the domain at the beginning, such as `example.com/comments/thread/123`.
#2: Post edited by user avatar trichoplax‭ · 2024-05-31T15:33:19Z (6 months ago)
Formating
  • The function `comment_thread_path` is created automatically by Rails, based on the information provided in `config/routes.rb`.
  • See [The Ruby on Rails guide to routing](https://guides.rubyonrails.org/routing.html) for further details.
  • Specifically, line 236 of `config/routes.rb` says (enclosing scope included for context):
  • ```ruby
  • scope 'comments' do
  • ...
  • get 'thread/:id', to: 'comments#thread', as: :comment_thread
  • ...
  • end
  • ```
  • This responds to a GET request on the route `/comments/thread/:id` by calling the `thread` method of the `CommentsController` (signified by `comments#thread`).
  • The `as: comment_thread` overrides the default name that Rails would otherwise use in its automatically generated helper functions (otherwise it would use the default `comments_thread` - note the pluralisation). Now `comment_thread_path` and `comment_thread_url` are available, each a function taking a thread id as argument.
  • Calling `comment_thread_path(123)` returns `/comments/thread/123`, and calling `comment_thread_url(123)` returns the same thing but including the domain at the beginning, such as `example.com/comments/thread/123`.
  • The function `comment_thread_path` is created automatically by Rails, based on the information provided in `config/routes.rb`.
  • See [The Ruby on Rails guide to routing](https://guides.rubyonrails.org/routing.html) for further details.
  • Specifically, line 236 of `config/routes.rb` says (enclosing scope included for context):
  • ```ruby
  • scope 'comments' do
  • ...
  • get 'thread/:id', to: 'comments#thread', as: :comment_thread
  • ...
  • end
  • ```
  • This responds to a GET request on the route `/comments/thread/:id` by calling the `thread` method of the `CommentsController` (signified by `comments#thread`).
  • The `as: comment_thread` overrides the default name that Rails would otherwise use in its automatically generated helper functions (otherwise it would use the default `comments_thread` - note the pluralisation). Now `comment_thread_path` and `comment_thread_url` are available, each a function taking a thread id as argument:
  • - Calling `comment_thread_path(123)` returns `/comments/thread/123`
  • - Calling `comment_thread_url(123)` returns the same thing but including the domain at the beginning, such as `example.com/comments/thread/123`.
#1: Initial revision by user avatar trichoplax‭ · 2024-05-31T15:30:40Z (6 months ago)
The function `comment_thread_path` is created automatically by Rails, based on the information provided in `config/routes.rb`.

See [The Ruby on Rails guide to routing](https://guides.rubyonrails.org/routing.html) for further details.

Specifically, line 236 of `config/routes.rb` says (enclosing scope included for context):

```ruby
scope 'comments' do
    ...
    get 'thread/:id', to: 'comments#thread', as: :comment_thread
    ...
end
```

This responds to a GET request on the route `/comments/thread/:id` by calling the `thread` method of the `CommentsController` (signified by `comments#thread`).

The `as: comment_thread` overrides the default name that Rails would otherwise use in its automatically generated helper functions (otherwise it would use the default `comments_thread` - note the pluralisation). Now `comment_thread_path` and `comment_thread_url` are available, each a function taking a thread id as argument.

Calling `comment_thread_path(123)` returns `/comments/thread/123`, and calling `comment_thread_url(123)` returns the same thing but including the domain at the beginning, such as `example.com/comments/thread/123`.