Rails runner
runs Ruby code in the context of Rails non-interactively.
eg. Rails runner 'puts Account.some_method_name' or
Rails r 'puts Account.some_other_method'
How to check for database name from Rails console ?
eg. ModelName.connection.current_database
Account.connection.current_database
Difference b/w :dependent => :destroy, :dependent => :delete
:dependent => :destroy
When a parent is deleted, ActiveRecord load every dependent record and calls a destroy on it.
:dependent => :delete
is called ActiveRecord issues a single SQL delete statement for the parent record's children.
How to restrict from generating default routes
1. resources :accounts, only: [ ]
2. resources :accounts, only: :none
and in case you would like to have one action(buy) then
resources :accounts, only: [:buy]
check for keyCode
&& which
& keyup
|| keydown
$(document).keydown(function(e){
var code = e.keyCode ? e.keyCode : e.which;
alert(code);
});
Replace single quote with backslash single quote
puts "Cote d'Ivoir".gsub("'", %q(\\\')) #=> Cote d\'Ivoir
How to make entire td a link?
td a {
display: block;
width: 100%;
height: 100%;
}
No comments:
Post a Comment