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 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 957 posted 12 years ago by cliffbraton
An example method for fetching remote JSON data in Ruby.
2 1131 posted 12 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 1063 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 1629 posted 13 years ago by brandonjp
if then statement... in a view file *.html.erb:
0 1530 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 677 posted 14 years ago by stayce
1 658 posted 14 years ago by wdso
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
1 622 posted 15 years ago by webstic
1 750 posted 16 years ago by pmaciver
2 930 posted 16 years ago by pmaciver
alternative to using DateTime.now.to_s
1 933 posted 16 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 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
« Prev 1 2 3