Welcome To Snipplr
Everyone's Recent Ruby Snippets Tagged rails
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
I had a spreadsheet with a ton of data on it that I wanted in my seeds file. Using example columns in your database titled db_column1, db_column2, db_column3. Place your .xls file into your public folder and run 'gem install roo'
0
901
posted 10 years ago by asalgan
If you're using Rails and want to make this a global function, drop this into your application_controller and call it as a function.
Example:
# get_string_between("hellomyfriendmoto", 'o', 'm')
# > myfriend
0
1401
posted 11 years ago by joshmn
= Rake Task for Rails
* name: name of the task
* desc: description of the task
0
956
posted 12 years ago by cliffbraton
Ruby
Ruby / Rails - A refresher reference for me because I forget... create project generate scaffold scaffolding migrate db
Ruby / Rails - A refresher reference for me because I forget how to do this... create project generate scaffold scaffolding migrate db start server
0
1062
posted 13 years ago by brandonjp
links (full <a href="#"> element) to Show Edit Destroy Delete records in view *.erb
must be in the record loop:
0
1627
posted 13 years ago by brandonjp
validate :price_must_be_at_least_a_cent
protected def price_must_be_at_least_a_cent
errors.add(:price, 'should be at least 0.01') if price.nil? || price < 0.01
end
0
676
posted 14 years ago by stayce
Easy way to add belongs_to association to nested forms in Rails
0
908
posted 14 years ago by viatropos
Code for a Rake task that allows compiles all LESS stylesheets (.less) contained within a single directory.
0
772
posted 15 years ago by brettbergeron
I didn't create this but I use it all the time. Just drop it in lib/tasks/fixtures.rake
1
665
posted 16 years ago by markpercival
"When using haml, an HTML tag is represented using %tagname, but in the case of an HTML tag with attributes, the representation is %tagname{:attribute => value}.
It turns out there must be no whitespace between %tagname and {:attribute => value}....
1
752
posted 16 years ago by cczona