ruby - Questions regarding link_to function within Rails -


executive summary

  1. reading api , have working "link_to", through brute force guessing.
  2. providing api , description, , attempting figure out how brute force guess worked!?

== end

i trying learn "how read api documentation within rails". 1 specific function gives me great deal of trouble link_to function. plain , simple, need learn how 'read api functions' , question related that.

url: http://apidock.com/rails/v4.0.2/actionview/helpers/urlhelper/link_to

the current documentation details following

1. link_to(body, url, html_options = {})   # url string; can use url helpers   # posts_path  2. link_to(body, url_options = {}, html_options = {})   # url_options, except :method, passed url_for  3. link_to(options = {}, html_options = {})   # name end  4. link_to(url, html_options = {})   # name end 

ultimately, wanted to add whole bunch of html styling , leveraging ajax link_to feature using block.

this worked, don't understand why option #4 used , not option #3 according prototype?

this worked:

<%= link_to session_path(@account.id), {remote: true, :method => :delete, id: "abc",style: "display:inline-block; top: 20px; color: red; outline: none;" } %>             <span class="glyphicon glyphicon-log-out" style: "display:inline-block; top: 20px; color: red; outline: none;"></span>             <span id="nav_loginout_action" style= "top: 20px; color: none; outline: none;display:inline-block;margin-left: 5px;">              logout </span>             <% end %> 

this did not

however if notice {remote:true, method => delete} being used options, , {id: "abc",style: "display:inline-block; top: 20px; color: red; outline: none;"} html_options

<%= link_to session_path(1), {remote: true, :method => :delete}, {id: "abc",style: "display:inline-block; top: 20px; color: red; outline: none;" } %>                 <span class="glyphicon glyphicon-log-out" style: "display:inline-block; top: 20px; color: red; outline: none;"></span>                 <span id="nav_loginout_action" style= "top: 20px; color: none; outline: none;display:inline-block;margin-left: 5px;">                  logout </span>                 <% end %> 

can explain how read rails documentation?

in particular

here troubles me:

in documentation options = {} defined ".... :data, :method , remote:true.  

in option 4 requires html_option (**not options, requested within option #3 **). see url link provided

the only, , repeat place options hash mentioned in option 3! tried use option #3, wasn't sure #name was. issue... (that wondering). main issue @ moment how html_options magically means options.

my worry not sure how read of these docs, ability self-help limited. please help.

i've understood concern. have checked why (first link_to gave) works reading source. checking remote , method keys in html options passed link_to , not in url_options (except remote). in docs list options can take field, instead of 'html_options', gave 'options', made appear options options , url_options not html_options. of course seemed magical works way said kind of info. 'url_options' , 'options' same, think it's mistake in doc.

the call in second case not matched of available signatures (argument lists). , yeah, # name inside block means contents should come inside anchor tags. think # link content more appropriate there.

so think isn't (you sure of how read docs), there inconsistencies said. :)


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -