Arquivo da tag: Rails

JavaScript file per view in Rails

https://stackoverflow.com/questions/602147/javascript-file-per-view-in-rails

Load the main JavaScript in application.js every time. Now create files for different needs. Create a form.js file, a myfancypart.js file etc. Don’t load them in the application.html.erb layout. Load them dynamically when you need them:

application.html.erb:

<%= javascript_include_tag "application" %>
<%= yield :javascript_includes %>

top of your view.html.erb:

<% content_for :javascript_includes do %>
  <%= javascript_include_tag "forms.js" %>
<% end %>

Everything in the content_for block will be loaded at yield :javascript_includes.

Share and Enjoy !

0Shares
0 0

Puma Auto Tune

Share and Enjoy !

0Shares
0 0

Deploy Your Rails App

https://www.sitepoint.com/deploy-your-rails-app-to-aws/
https://www.phusionpassenger.com/library/deploy/apache/automating_app_updates/ruby/

Share and Enjoy !

0Shares
0 0

How to use the “number_to_currency” helper method in the model rather than view?

class MyPresenterOrViewModel
  def some_field
    helper.number_to_currency(amount, :precision => 0)
  end

  private

  def helper
    @helper ||= Class.new do
      include ActionView::Helpers::NumberHelper
    end.new
  end
end
https://stackoverflow.com/questions/5176718/how-to-use-the-number-to-currency-helper-method-in-the-model-rather-than-view/5867154

Share and Enjoy !

0Shares
0 0