Welcome To Snipplr


Everyone's Recent Snippets Tagged rails



1 1201 posted 18 years ago by jpowell
1 848 posted 18 years ago by jpowell
1 898 posted 18 years ago by jpowell
1 927 posted 18 years ago by jpowell
1 940 posted 18 years ago by jpowell
1 788 posted 18 years ago by greystate
This is an easy to use any helpers that rails provides in any other place besides views and view helpers
1 1014 posted 18 years ago by vanne
This redirects visitors to a new URL using a 301 redirect. Using a 301 redirect is the safest way to let search engines like Google, Yahoo!, Live and Ask know your address has changed.
3 2122 posted 18 years ago by jonhenshaw
Put this in environment.rb to use in your whole app or the console
1 975 posted 18 years ago by vanne
0 1024 posted 18 years ago by drewr
Renders the partial template called 'cart', sends along local variable @cart, this will be known locally using the same name as the partial, 'cart'.
1 961 posted 18 years ago by wackimonki
The code tests if session[:counter] exists. If you leave out the all important '?', it will fail with an error.
1 1113 posted 18 years ago by wackimonki
This will add up all the prices and return it? What does |item| mean exactly?
2 943 posted 18 years ago by wackimonki
Redirects from one method to another in a controller. This is handy when there's an error, and you need to go back to index page, or for other purposes.
1 1016 posted 18 years ago by wackimonki
Adds a button in view, which triggers a method. "Empty cart" is the button name empty_cart is the method name
1 898 posted 18 years ago by wackimonki
Catches an exception error, uses a technique called flash to display error on another page. The Ruby on Rails code needs to be in a controller. The rhtml code needs to be in the index layout.
1 958 posted 18 years ago by wackimonki
Add this inside your .irbrc file to call "show Model" in your console instead of "y Model.column_names"
1 973 posted 18 years ago by vanne
Displays a image inside link_to instead of text.
2 1070 posted 18 years ago by ryanprel
0 1313 posted 18 years ago by sudarkoff
Add this to your ~/.irbrc file and you will have inline logging in the console
1 911 posted 18 years ago by vanne
Use this to sanitize a string and convert all wierd characters to your choice of delimiter
1 1020 posted 18 years ago by vanne
Define multiple associations on the same associated class. From the Rails Way blog.
1 836 posted 18 years ago by gnatware
3 1214 posted 18 years ago by zuwiki
0 848 posted 18 years ago by spider
used to remove unnecessary duplication of code. Code is from Jamis Buck (http://weblog.jamisbuck.org/2007/1/24/object-with_options)
1 915 posted 18 years ago by andyh
put this into lib/tasks and then run rake db:version
1 901 posted 18 years ago by vanne