On Martes, 14 de Julio de 2009 03:08:26 Paul Taylor escribió:
> Sergio,
>
> I didn't understand how the code you posted would help, so I figured
> I'd just try it on my dev system.  I placed this in my utms_helper.rb
> file:
>
> module UtmsHelper
>   def options_for_association_conditions(association)
>     if association.name == :store
>       {'utms.store_id' => nil}
>     else
>       super
>     end
>   end
> end
>
> When trying to edit a utm, I'm now getting:
>
> SQLite3::SQLException: no such column: utms.store_id: SELECT * FROM
> "stores" WHERE (("utms"."store_id" IS NULL))
>
> It sounds like this might be helpful if I could get a join going on
> here...

There is no way to add a join, so you need to override association_options_find 
too:
  def association_options_find(association, conditions = nil)
    if association.name == :store
      association.klass.find(:all, :include => :utms, :conditions => 
controller.send(:merge_conditions, conditions, 
association.options[:conditions]))
    else
      super
    end
  end


>
> Just to clarify, here are the rake files for the two tables.  As you
> can see, the stores table makes no reference to the utm table.
>
> class CreateStores < ActiveRecord::Migration
>     def self.up
>       create_table :stores do |t|
>         t.string  :name
>       end
>     end
>
>     def self.down
>       drop_table :stores
>     end
> end
>
> class CreateUtms < ActiveRecord::Migration
>     def self.up
>       create_table :utms do |t|
>         t.integer  :store_id
>               t.string   :name
>               t.string   :key
>       end
>     end
>
>     def self.down
>       drop_table :utms
>     end
> end
> 
-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to