ruby on rails - Why is a symbol used next to the word "to" in the code below? -


this question has answer here:

coming php, not sure why symbol below used on right hand side of to.

get '/posts/new', to: 'posts#new' 

is hash key , whats in quotes key?

been looking @ rails tutorials , never seen hash in kind of form wondering...

yes, correct, to: hash key.

when hash last argument in list ruby allows forego use of curly braces.

perhaps clearer when add parentheses , curly braces:

get('/posts/new', { to: 'posts#new' }) 

that line calls get method 2 arguments. first argument string '/posts/new'. second 1 hash { to: 'posts#new' }.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -