ruby - Rails - Maximum Use of Symbols in Views -


i have stumbled upon thinking block , wanted have input pros.

i using rails , here sample code views:

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { id: "confirmation", method: :post }) |f| %>   <%= devise_error_messages! %>    <div class="form-group">     <%= f.label :email %>     <%= f.email_field :email, autofocus: true, class: "form-control" %>   </div>    <div class="form-group">     <%= f.submit "resend confirmation instructions", class: "btn btn-primary" %>   </div> <% end %> 

i think can replace strings symbols memory efficient so:

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { id: :confirmation, method: :post }) |f| %>   <%= devise_error_messages! %>    <div class="form-group">     <%= f.label :email %>     <%= f.email_field :email, autofocus: true, class: :'form-control' %>   </div>    <div class="form-group">     <%= f.submit "resend confirmation instructions", class: { :btn, :'btn-primary' } %>   </div> <% end %> 

is assumption correct? boundary between using symbols , strings quite thin 1 how 1 decide use or should 1 use symbols? should code readability factor?

on long run might not want follow way,.

as rails has memory concerns,

symbol.all_symbols.count

will give idea how many initialized already, why want add few more, use strings mutable.

in worst case if user sent params converted symbol might in big trouble, lead dos(denial of service)

just very minor difference, may paying more later on.

on ruby 2.2, there incremental gc, better solution this.

at times our application seems running memory > 90%, been problem @ times. safeguard from beginning, later don't need crack.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -