Just to make sure: You are aware, that sharing all helpers in all
controllers is "only" a default, and can be changed? Check "
helper :all # include all helpers, all the time
" in application_controller.rb.

Regards
Michael

On 4 Mai, 02:44, Soren Christensen <[email protected]> wrote:
> I think this is what delegate_to is intended for.
>
> I have used it that way a couple of times with great results.
>
> Alternatively you can also define a bunch of virtual fields that then
> just references the 'other' model.
>
> So assume one is called model_a and the other is model_b
>
> Model_b can then have columns that are defined as:
>
>    def address
>      self.user.address unless self.user.nil?
>    end
>
> /S
>
> On 5/3/2010 4:37 PM, Iñaki Baz Castillo wrote:
>
>
>
>
>
> > Hi, I've two models sharing the same table and have realized about a
> > possible bug or strange behavior in Rails 2.3:
>
> > - In both models I define the same table name (of course):
> >       def self.table_name() "address" end
>
> > - Then I create a helper for each model/controller, but the methods I
> > define on one of them are shared by both controllers!
>
> > Well, to avoid it I've created a VIEW, with same columns as the
> > original "address" table has.
> > Then I get an error when accessing to the new controller:
>
> > ActionView::TemplateError (undefined method `primary_key' for
> > 2:Fixnum) on line #6 of
> > vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.er 
> > b:
> > 3: dont_show_calculations ||= false
> > 4: tr_class = cycle("", "even-record")
> > 5: tr_class += " #{list_row_class(record)}" if respond_to?
> > :list_row_class
> > 6: url_options = params_for(:action =>  :list, :id =>  record.id)
> > 7: -%>
> > 8:
> > 9:<tr class="record<%= tr_class %>" id="<%= element_row_id(:action
> > =>  :list, :id =>  record.id) %>">
>
> >      activerecord (2.3.4) lib/active_record/base.rb:2448:in `id'
> >      
> > vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.er 
> > b:6
> >      actionpack (2.3.4) lib/action_view/renderable.rb:34:in `send'
> >      actionpack (2.3.4) lib/action_view/renderable.rb:34:in
> > `render_without_active_scaffold'
> >      actionpack (2.3.4) lib/action_view/base.rb:301:in `with_template'
> >      actionpack (2.3.4) lib/action_view/renderable.rb:30:in
> > `render_without_active_scaffold'
> >      
> > vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:94:i 
> > n
> > `render'
> >      actionpack (2.3.4) lib/action_view/renderable_partial.rb:20:in
> > `render'
> >      actionpack (2.3.4) lib/action_controller/benchmarking.rb:26:in
> > `benchmark'
> >      activesupport (2.3.4)
> > lib/active_support/core_ext/benchmark.rb:17:in `ms'
> >      /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
> >      activesupport (2.3.4)
> > lib/active_support/core_ext/benchmark.rb:17:in `ms'
> >      actionpack (2.3.4) lib/action_controller/benchmarking.rb:26:in
> > `benchmark'
> >      actionpack (2.3.4) lib/action_view/renderable_partial.rb:19:in
> > `render'
> >      actionpack (2.3.4) lib/action_view/template.rb:199:in
> > `render_template'
> >      actionpack (2.3.4) lib/action_view/renderable_partial.rb:44:in
> > `render_partial'
> >      actionpack (2.3.4) lib/action_view/partials.rb:221:in
> > `render_partial_collection'
> >      actionpack (2.3.4) lib/action_view/partials.rb:216:in `map'
> >      actionpack (2.3.4) lib/action_view/partials.rb:216:in
> > `render_partial_collection'
> >      actionpack (2.3.4) lib/action_view/partials.rb:182:in
> > `render_partial'
> >      actionpack (2.3.4) lib/action_view/base.rb:262:in
> > `render_without_active_scaffold'
> >      
> > vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:61:i 
> > n
> > `render'
> >      
> > vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb:16
> >      actionpack (2.3.4) lib/action_view/renderable.rb:34:in `send'
> >      actionpack (2.3.4) lib/action_view/renderable.rb:34:in
> > `render_without_active_scaffold'
> >      actionpack (2.3.4) lib/action_view/base.rb:301:in `with_template'
> >      actionpack (2.3.4) lib/action_view/renderable.rb:30:in
> > `render_without_active_scaffold'
> >      
> > vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb:94:i 
> > n
> > `render'
>
> > Should active_scaffold work ok when using a MySQL VIEW?
> > Thanks.
>
> --
> 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 
> athttp://groups.google.com/group/activescaffold?hl=en.

-- 
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