Quantcast
Channel: Master Ruby/Rails Programming
Browsing all 25 articles
Browse latest View live

POSTing and PUTting from cURL

>curl -X PUT -d "post[title]=first post from curl""http://localhost:3000/posts/1" -H "Accept: text/xml">curl -d "post[title]=first post from curl""http://localhost:3000/posts" -H "Accept:...

View Article



DangerousAttributeError

I came across this weird sounding exception while creating a record. At first I didn't know what was wrong with my table. After a little probing I figured it was being caused by an attribute called...

View Article

File.new

File.new(file_name).close won't do what I intend to do, i.e. create a file. Instead File.new(file_name,'w').close does the trick. The problem is in the first case the second argument defaults to 'r'...

View Article

Padding numbers

If you want output as 123.90:sprintf("%0.2f","123.9")

View Article

Add localhost.localdomain to local DNS (or hosts file)

Goto Start > Run Type in "system32" (without the quotations) Goto the folder called "drivers" Goto the folder called "etc" The hosts file should be in there. Just open it up with notepad or...

View Article


Migrating in a production environment

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

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

TextMate discoveries

Option+Apple+o = Overwrite mode

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


Duplicating a table in MySQL

CREATE TABLE duplicate_name SELECT * FROM original_table;

View Article

Find out mysql socket

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

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

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


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

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


Installing sqlite for rails development

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

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


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

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

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
Browsing all 25 articles
Browse latest View live




Latest Images