Welcome To Snipplr


Everyone's Recent Rails Snippets



« Prev 1 2 3 4 5
Git log to see deleted line
0 68 posted 5 years ago by yaworsk
Use rescue_from ActiveRecord::RecordNotUnique when DB transaction fail on uniqueness check
0 64 posted 5 years ago by yaworsk
Useful for building nested entries checkboxes etc
0 92 posted 5 years ago by davidb
A very concise ruby on rails helper method that converts seconds into human readable format. It will not display any time periods that have 0 (ie: 1 hour 13 seconds - skipping minutes as there were none) Due to complexity, months were not factored...
0 158 posted 6 years ago by uberdragon
You want to start a new Rails app. But you also want to start a new RVM gemset for the app so you can start with the latest Rails and gems. In this code snippet I show how I start off an up-to-date Rails project in a clean gemset.
1 79 posted 6 years ago by dreamstarter
Supported brands name | key ----------------------- American Express | :amex China UnionPay | :unionpay Diners Club | :diners Dinner Club US | :diners_us Discover | :discover...
0 104 posted 7 years ago by Fivell
Working on the problem described here: http://forums.att.com/t5/Data-Messaging-Features-Internet/3G-proxy-wnsnet-attws-com-strips-HTTP-response-headers/m-p/3294533/highlight/false#M59737 After some testing we found the below code to fix our troubl...
0 94 posted 7 years ago by mightybs
render :layout => false not work
0 79 posted 8 years ago by CrescentMoon
Esto suele ocurrer muy amenudo cuando instalamos Ruby on Rails antes que MySQL. Es un error "Library not loaded: libmysqlclient.18.dylib (LoadError)" donde lista los directorios donde busca y no lo encuentra. La solución es guiarle para que lo encue...
0 89 posted 8 years ago by skozz
0 83 posted 8 years ago by abstraktor
If each title is unique and you need alphabetical, try this in your Post model. You can change title to any unique attribute (created_at, id, etc.) if you need a different sort order.
0 65 posted 9 years ago by gmericksen
0 86 posted 9 years ago by batamire
This will require a user to log back in if they are inactive for more than 10 minutes. In order for this feature to be used you must have a last_request_at datetime column in your table for whatever model you are authenticating with.
0 58 posted 9 years ago by gmericksen
0 84 posted 9 years ago by alx_g
tag links with .click function
0 66 posted 9 years ago by insanedreamer
Put this in application layout for global use. Have a hidden div called 'loadicon' with a loading icon (or whatever) in it, which is shown/hidden on ajax calls.
0 76 posted 9 years ago by insanedreamer
0 60 posted 9 years ago by almazom
Migrating a Rails app from Development to Production can sometimes be a real pain. One way I help reduce headache is by copying all the necessary Rails files to make it a self-contained unit (Freezing). If I need to make version changes later, I si...
0 44 posted 9 years ago by chrisaiv
Here are a few examples of how to install my favorite rails plug-ins from GIT. The alternative solution is to simply use gem --and have the plugin available throughout all of my rails applications-- but I prefer to have my applications living as sel...
0 80 posted 9 years ago by chrisaiv
Add this to .irbrc. Allows the following in console: > gethtml('/login') => HTML of whatever page is generated by /login
0 75 posted 9 years ago by insanedreamer
in Rails 2, use `include ActionController::UrlWriter` instead.
1 128 posted 9 years ago by insanedreamer
Put this in `test_helper.rb` and call with `show(object1, object2, etc.)`
0 60 posted 9 years ago by insanedreamer
« Prev 1 2 3 4 5