Demystifying Ruby ERB Code -


ruby on rails newbie question...

consider following code (which within view):

<div class="meta"> <%= link_to time_ago_in_words(status.created_at) + " ago", status %> | <span class="admin"> <%= link_to "edit", edit_status_path(status) %> | <%= link_to "delete", status, method: :delete, data: { confirm: "ya sure?" } %> </span> </div> 

some of methods called within erb tags seem magic me, , i'm trying demystify them. don't feel comfortable using code if don't understand how works under hood.

can point me following methods (er, think methods, maybe that's not right term) defined and/or documented?

  • edit_status_path()
  • :delete
  • data:
  • confirm:

there 1 method here: edit_status_path. created within routes file (config/routes.rb), moethod called resources (in case resources :statuses).

:delete not method, symbol: http://www.ruby-doc.org/core-2.1.2/symbol.html

data: alone has no meaning in ruby, comes second part (like data: value). ruby syntax hash object: http://www.ruby-doc.org/core-2.1.2/hash.html, using symbols keys. so

{a: 1} 

is same as

{:a => 1} 

i don't feel comfortable using code if don't understand how works under hood. - understand completely. advise read ruby book (not ruby on rails) before start learning rails (and start book well). fact started learning ruby rails reason why hated language couple of months before fall it.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -