justinfrench/formtastic — pull request #928 by kenmazaika (2013-03-27 18:53:06+00:00)
Title: Fix Rails4 deprecation errors when getting a collection from an association

**NOTE: this isn't ready to merge yet. it's untested and there are broken tests.**

Before I spent too much time tidying this up, I figured I'd show you the fix that I made.

When upgrading to Rails4 I found that formtastic was producing this deprecation warning:

```
DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead. (called from collection_from_association at /Users/kmazaika/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/bundler/gems/formtastic-dc16ffc3dd5f/lib/formtastic/inputs/base/collections.rb:93)
```

Digging into it, it seems there are two problems here:

1 - `.scoped(scope_conditions)`. Calling the scoped method is deprecated in Rails4 as indicated by the message.
2 - Using conditions with relationships is also deprecated in Rails4. Scopes should be used instead.

For example having a relationship defined by:

```
has_many :yolos, :conditions => "swag_id is not null"
```

Produces the following deprecation message:

```
DEPRECATION WARNING: The following options in your Fomo.has_many :yolos declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:

has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'

should be rewritten as the following:

has_many :spam_comments, -> { where spam: true }, class_name: 'Comment'

```

So the correct way to write this would be:

```
has_many :yolos, -> { where("swag_id is not null") }
```

Before I fix the tests and write new ones, I wanted to run this by you guys. Let me know if you have feedback, and I'll adjust the pull request accordingly.