Quantcast
Channel: Master Ruby/Rails Programming
Browsing index pages (25 articles)

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 Article


Missing 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 Article


Export 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 Article

IRB 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 Article

Anonymous 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 Article


Errno::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 Article

Using 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 Article

after_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 Article


Current 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 Article


Installing sqlite for rails development

sudo apt-get install sqlite3sudo gem install sqlite3-rubyrails my_projectrake db:create

View Article

Duplicating 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 Article

Common 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 Article

Sorting 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 Article


Basic 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 Article

Find out mysql socket

Enter mysql command line with 'mysql -u root -p'mysql>mysql status

View Article


Duplicating a table in MySQL

CREATE TABLE duplicate_name SELECT * FROM original_table;

View Article

GIT - 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 Article


TextMate discoveries

Option+Apple+o = Overwrite mode

View Article

Getting 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 Article

Migrating in a production environment

rake db:migrate RAILS_ENV=productionorrake db:migrate RAILS_ENV="production"

View Article
Browsing index pages (25 articles)


Latest Images