This is the code for getting and creating messages.
get ‘/messages’ => ‘messages#index’
get ‘/messages/new’ => ‘messages#new’
post ‘messages’ => ‘messages#create’
I don’t understand why there is no forward slash before ‘messages’ in the post route, whereas the get routes do… Anybody have any explanations?
My code works fine with no forward slashes on any of the routes.
In an URL an immediate forward slash implies a root directory. In this case,
Rails must ignore it when we add the slash (in this environment) since the code works fine either way, with or without the slashes. I cannot accurately explain what the case might be in a real world environment. Bears more reading if you really want an answer. Meanwhile, I’ll invite a member who is better versed in Rails…
@althea.4 You don’t need to begin any of those routes with a forward slash (
/), Rails is designed to make developing a website as easy as possible for the user and so it will interpret the route correctly regardless of whether you start the route with a forward slash or not
Not sure if there’s anything besides that and @mtf’s answer, though.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.