Difference between "and" and "&&"
klasses = ['last'] && txt = '' if idx == (tabs.length - 1)At the end of this statement klasses will contain "".klasses = ['last'] and txt = '' if idx == (tabs.length - 1)At the end of this...
View ArticleMissing gems even though they are present
Have you seen the following only to realize all those are already installed?Missing these required gems: rspec = 1.3.0 rspec-rails = 1.3.2My environment.rb has entries for both of them like:config.gem...
View ArticleExport MySQL query result to a CSV file
SELECT a,b,a+b INTO OUTFILE '/tmp/result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM...
View ArticleIRB tricks: assign last statement's return value to a var
irb(main):001:0> 1+2=> 3irb(main):002:0> a=_=> 3irb(main):003:0> a=> 3Underscore assigns the last executed statement's return value to a.
View ArticleAnonymous functions
An interesting fact:var sum = function(x,y,z) { return (x+y+z);}(1,2,3);is an anonymous function. That means sub is now 6. If you call sum with any arguments it will bark at you. Where as this:var sum...
View ArticleErrno::ECONNREFUSED: Connection refused - connect(2)
Errno::ECONNREFUSED: Connection refused - connect(2)If you get this error, one of the reason could be incorrect or no ActionMailer settings. The following structure needs to be present in your...
View ArticleUsing define_method to create a method that takes arguments
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/211436http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/211440Example:Setting.all.each do |setting|define_method setting.name do...
View Articleafter_initialize and after_find can't be private
after_initialize and after_find can't be private. Another note: they need to be explicitly define like:def after_initialize# do stuff here.end
View ArticleCurrent option not getting selected in select box?
I have a f.select(:attr1, options) in one of my form. But after I submit and if there are any errors in the form it should show the errors and retain all the values in the form. But this attr1 was...
View ArticleInstalling sqlite for rails development
sudo apt-get install sqlite3sudo gem install sqlite3-rubyrails my_projectrake db:create
View ArticleDuplicating tables and problem with the structure
To duplicate a table:mysql> CREATE TABLE products SELECT * FROM old_products;But the problem with above statement is structure of products may not be the same as old_products. Attribute properties...
View ArticleCommon MySQL stuff
To modify an existing column definition:ALTER TABLE applications modify id INTEGER NOT NULL AUTO_INCREMENT FIRST;To rename a column:ALTER TABLE applications CHANGE old_col new_col;
View ArticleSorting records based on the exact order of passed parameters to finder
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/dde7efa8f8f455e5/e4090afeb6c27608?lnk=gst&q=loveajax#e4090afeb6c27608In Ruby:order = [5,2,3]Project.find(:all, :conditions =>...
View ArticleBasic Authentication using Apache and mod_rails
http://code.google.com/p/phusion-passenger/issues/detail?id=94&can=1&q=allow&colspec=ID%20Type%20Status%20Priority%20Milestone%20Stars%20SummaryCopy pasted from the above link:What steps...
View ArticleFind out mysql socket
Enter mysql command line with 'mysql -u root -p'mysql>mysql status
View ArticleGIT - Ignore uncommitted changes in already tracked files
in order to ignore uncommitted changes in already tracked files, please refer to the git update-index --assume-unchanged documentationhttp://www.kernel.org/pub/software/scm/git/docs/git-update-index.html
View ArticleGetting the text from a drop down select box
var e = $('element_id');var idx = e.selectedIndex;e.options[idx].text;Linkshttp://www.webdevelopersnotes.com/tips/html/getting_the_text_from_an_html_drop_down_selection_list.php3
View ArticleMigrating in a production environment
rake db:migrate RAILS_ENV=productionorrake db:migrate RAILS_ENV="production"
View Article