Welcome To Snipplr


Everyone's Recent Ruby Snippets Tagged rails



« Prev 1 2 3
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 29 posted 6 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 65 posted 6 years ago by joshmn
= Rake Task for Rails * name: name of the task * desc: description of the task
0 30 posted 7 years ago by cliffbraton
An example method for fetching remote JSON data in Ruby.
2 51 posted 8 years ago by vestimir
Ruby / Rails - A refresher reference for me because I forget how to do this... create project generate scaffold scaffolding migrate db start server
0 19 posted 9 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 28 posted 9 years ago by brandonjp
if then statement... in a view file *.html.erb:
0 61 posted 9 years ago by brandonjp
This script is a nice balance between validating data and speed.
1 18 posted 9 years ago by chrisaiv
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 12 posted 9 years ago by stayce
1 7 posted 10 years ago by wdso
Easy way to add belongs_to association to nested forms in Rails
0 16 posted 10 years ago by viatropos
Code for a Rake task that allows compiles all LESS stylesheets (.less) contained within a single directory.
0 17 posted 10 years ago by brettbergeron
1 11 posted 10 years ago by webstic
2 21 posted 11 years ago by pmaciver
alternative to using DateTime.now.to_s
1 33 posted 11 years ago by jhenry
I didn't create this but I use it all the time. Just drop it in lib/tasks/fixtures.rake
1 13 posted 11 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 22 posted 12 years ago by cczona
« Prev 1 2 3