Home
Ruby on Rails
Cheatsheets
<% form_for(@customer, :html => { :multipart => true }) do |f| %> <%= f.file_field :image_file %> <%= submit_tag %> <% end %>
class Customer < ActiveRecord::Base def image_file =(uploaded_data) self.filename = uploaded_data.original_filename self.image_data = uploaded_data.read self.size = uploaded_data.size self.content_type = uploaded_data.content_type end end
Sometimes you want to quickly see the output of helper methods, and constantly clicking refresh in your browser then viewing the page source can be tiresome. Instead, use the Rails console to check helpers are doing what you want them to.
More