Category Archives: software engineering

Paperclip requires multipart set to true in form_for

Even though I’ve been using Paperclip for a few years now, I still forget to add that one parameter to the form. You know? The one that will actually make things work. 1234<%= form_for :file, :html => { :method => :post, :multipart => true} do |f| -%>   <%= f.file_field :attachment %>     <%= [...]

Also posted in Ruby programming, web programming | Tagged , , , , , | 2 Comments

Liquid error: undefined method ‘paginate’ for Array (WillPaginate 3.0)

If you ever find this problem (Github Issue) you should know that WillPaginate 3.0 isn’t backwards compatible. This also is tightly coupled with the new Active Record implementation (Now it returns ActiveRecord::Relation, which are lazy arrays) This solved the problem I was having: 12  # app/config/initializers/liquid.rb   require ‘will_paginate/array’ Be careful when you upgrade your [...]

Also posted in open source, programming, Ruby programming, web programming | Tagged , , , , , | Leave a comment

How to load all fixtures testing with RSpec 2 and Rails 3

Anyway, if you want to have RSpec 2 load all of the fixtures (in your spec/fixtures directory) to your database and test your Rails 3 app, you need have this configuration:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
RSpec.configure do |config|
  # == Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock
  # config.mock_with :rr
  config.mock_with :rspec

  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
  config.fixture_path = "#{::Rails.root}/spec/fixtures"

  # If you're not using ActiveRecord, or you'd prefer not to run each of your
  # examples within a transaction, remove the following line or assign false
  # instead of true.
  config.use_transactional_fixtures = true

  # This will pick up all of the fixtures defined in spec/fixtures into your
  # database and you'll be able to test with some sample data
  # (eg. Countries, States, etc.)
  config.global_fixtures = :all
end
Also posted in developer tools, open source, programming, Ruby programming, web programming | Tagged , , , , , , , , | Leave a comment