Sorry, I meant the section on conditions on a belongs_to:
4.1.3 Scopes for belongs_to

There may be times when you wish to customize the query used by belongs_to.
Such customizations can be achieved via a scope block. For example:
    class Order < ActiveRecord::Base
   belongs_to :customer, -> { where active: true },
                         dependent: :destroy
 end


​Still, I think my bigger problem is operating with Hobo outside of the
warm blanket of Rails.

T​



On Wed, Jan 29, 2014 at 12:35 PM, Tim Griffin <[email protected]> wrote:

> Hey Kevin;
>
> Nope, that syntax comes straight from the RailsGuides:
>
>
> http://guides.rubyonrails.org/association_basics.html#scopes-for-has-many-order
>
> See specifically section 4.3.3.1:
>
> 4.3.3.1 where
>
> The where method lets you specify the conditions that the associated
> object must meet.
>     class Customer < ActiveRecord::Base
>    has_many :confirmed_orders, -> { where "confirmed = 1" },
>      class_name: "Order"
>  end
>
> Tim
>
>
>
> On Wed, Jan 29, 2014 at 12:29 PM, kevinpfromnm <[email protected]>wrote:
>
>> Did you have a copy/paste issue there? -> doesn't match any ruby syntax I
>> know of.  I would think you'd want something like :keyname => ... in it's
>> place.
>>
>>
>> On Tuesday, January 28, 2014 1:39:25 PM UTC-7, Tim Griffin wrote:
>>>
>>>
>>> Hi all;
>>>
>>> In updating my app to Hobo 2.0.1, I'm having to make some changes as
>>> advised by Rails 4.
>>>
>>> One that's tripping up Hobo 2.0.1 is converting a :conditions parameter
>>> on a belongs_to to be a scope block.
>>>
>>> In a Title model, that means this:
>>>   belongs_to  :condo_holding_title, :class_name => "Title",
>>> :foreign_key => :condominium_holding_title, :conditions => "title_type
>>> = 'CondominiumHolding'"
>>>
>>> Needs to become this:
>>>   belongs_to  :condo_holding_title, -> { where("title_type =
>>> 'CondominiumHolding'") }, :class_name => "Title", :foreign_key =>
>>> :condominium_holding_title
>>>
>>> But the revised version is throwing:
>>>
>>> /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/hobo_
>>> fields-2.1.0/lib/hobo_fields/model.rb:86:in 
>>> `belongs_to_with_field_declarations':
>>> wrong number of arguments (3 for 2) (ArgumentError)
>>>
>>> As far as I can see, that method is declared with 3 arguments:
>>>
>>>     def self.belongs_to_with_field_declarations(name, options={},
>>> &block)
>>>
>>> Why is it expecting 2?
>>>
>>> Tim
>>>
>>>  --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Hobo Users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/hobousers/LFPHsqTg8p0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/hobousers.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to