Include a specific JavaScript file for a given view
Add <%= yield :javascript_includes %>
to application.html.erb
:
<%= javascript_include_tag "application" %>
<%= yield :javascript_includes %>
Add to top of your view.html.erb
:
<% content_for :javascript_includes do %>
<%= javascript_include_tag "forms.js" %>
<% end %>
Notes:
-
forms.js
should be located in theapp/assets/javascripts
directory. - To avoid duplicate inclussion of js files, you must disable the
require_tree
directive inapplication.js
. You just have to remove the equal sign...
JQuery. Match an element with 'active' class
#$('[id^=btn_tipo_movimiento].active').trigger('click')
Macthes an element whose id starts with 'btn_tipo_movimiento' and has the 'active' class
Avoid the annoying "Server asset... Not modified ..." messages on logs
There seems to be other ways to deal with this, but a simple filter with grep can help:
tail -f log/development.log | grep -vE "(^\s*$|asset)"
Thanks to: https://github.com/rails/rails/issues/2639
passenger basic commands
Start the server in 3002 port:
passenger start -p 3002
Start the server in daemon mode in production environment
passenger start -p 3002 \
-e production -d \
--log-file=/var/nginx/my_app/shared/log/passenger.3002.log \
--pid-file=/var/nginx/my_app/shared/log/passenger.3002.pid
Capistrano basic commands
Once you have the basic configuration file (see: Capistrano basic configuration), you can:
Initialize the deployment directory
cap deploy:setup
Verify that the deployment server has all the dependencies needed:
cap deploy:check
Deploy the changes
cap deploy:update
Tip: Don't forget to setup the databa...
Capistrano basic configuration
This is a simple Capistrano configuration file. It's based on the railcast: http://railscasts.com/episodes/133-capistrano-tasks, but it also handles multiple deployment targets.
set :application, "my_app_name"
set :scm, :git
set :repository, "ssh://git@bitbucket.org/username/my_app_name.git"
role :web, "my_app_name.com" # Your HTTP server, Apache/etc
role :app, "my_app_name.com" # This may be the same as your `Web` server
role :db, "my_app_name.com", :primary => true # This is where Rails m...