Welcome To Snipplr
Everyone's Recent Rails Snippets Tagged rails
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
I used to directly inject javascript and CSS into my HEAD elements just like you see in all of the tutorials online and in books. Recently I decided to try a different approach, and I feel this is more in keeping with the ruby and rails "declaration"...
0
1537
posted 15 years ago by sgtrock
I used to directly inject javascript and CSS into my HEAD elements just like you see in all of the tutorials online and in books. Recently I decided to try a different approach, and I feel this is more in keeping with the ruby and rails "declaration"...
0
1478
posted 15 years ago by sgtrock
I never can remember the exact name of the exception to call in self.down for a migration that cannot be undone. So I decided to come up with something easier to remember. This feels more "ruby-ish" and "rails-ish" to me, and so far it works just fin...
0
1137
posted 15 years ago by sgtrock
Regular menu item adding current class if current url equal menu item destination.
1
1427
posted 15 years ago by smoothdzion
I needed to make menu items that kept the current class based on the controller being accessed.
1
1186
posted 15 years ago by smoothdzion
I needed to copy the value of one field to a couple of others in case users decided to forget to fill them out. Using jQuery and added it to a helper because I was using in multiple places. Created variables to make it more readable.
1
1214
posted 15 years ago by smoothdzion
The code to find all objects from a model and use them as select options.
1
1438
posted 15 years ago by smoothdzion
For separating a list of categories with a comma that are linked. There may be a better way. Leave a comment if you have a better way. This was the first way I found that worked.
This code increments the count 1 at a time. It applies the incre...
1
1102
posted 15 years ago by smoothdzion
Used to create checkboxes to select multiple categories for a post or any other type of applicable situation.
1
1056
posted 15 years ago by smoothdzion
requires Rails libraries. could be rewritten to just use core Ruby libs, but I'm too lazy right now and I use this entirely in my Rails apps.
0
1464
posted 15 years ago by mepatterson
This could be further abstracted to work with other db's. Also, it really should be using Ruby's Tempfile class instead of assuming the local machine is *NIX based, but it works :)
0
1258
posted 16 years ago by nate63179
In this instance, used as an after-deploy hook to create a symlink to a shared db config file
0
1351
posted 16 years ago by nate63179
Rails
will_paginate with jquery ajax / поÑтаничный вывод в Rails Ñ will_paginate и Jquery
0
1596
posted 16 years ago by almazom
Rails
olark service using with rails and haml / иÑпользование Olark ÑервиÑа Ñ Rails и Haml
0
1378
posted 16 years ago by almazom
Можно выкладывать даже файлы, Ñодержащие кириллицу в названии. Они будет подвергнуты транÑлитерации, пробелы и другие небезопаÑные ÑимÐ...
0
1401
posted 16 years ago by almazom
creates something like list_49 with the 49 corresponding to id of record in database.
0
1148
posted 16 years ago by deschism
Put the following in your controller to define the content-type for *that* specific controller.
0
1006
posted 16 years ago by chrisamini
The 'request' and 'response' objects are chock full of useful info. But console can't usually access them. Here's how:
start the server with the -u option, insert a breakpoint where you would like to have access to the controllers/helpers/etc. Wh...
1
1587
posted 16 years ago by cczona
Populate your states table with US States. Easy rake task for it.
2
1498
posted 16 years ago by twofivethreetwo
I normally paste this into config/mongrel.rb, then add "require 'mongrel'" in my config/deploy.rb
Once that's done, you'll be able to start, stop, and restart your mongrels like so:
`cap deploy:mongrel:start/stop/restart`
3
1417
posted 17 years ago by jimmyebaker