Hi Soren,

ActiveScaffold is a CRUD tool and the founders decided to bind any
active_scaffold configuration to an ActiveRecord model.
Activerecord model needs a database table or view to work correctly.

It seems to me that you just would like to report/list data (so no
update, create, delete ??)

I think you have the following options:
1. Pick database table for your model which includes most of the
attributes
2. Create a view and use that as a base for your model
3. I think there are plugins which remove the ActiveRecord - Table/
View dependency

I bet there are even more options...

--
Volker





On 24 Sep., 23:21, Soren <[email protected]> wrote:
> I like the idea of using a delegate in AR.
>
> In particular because my controller is really just trying to be enough
> of a controller to show AS List & Search.
>
> So my model would say something like:
> class MatchingGrant < ActiveRecord::Base
>
>   [:first_name, :last_name, ...}.each { |m| delegate m, :to => :user }
>
>   [:empl......].each { |m| delegate m, :to => :form }
>
>   ...Additional delegations here ...
>
> end
>
> And my controller would say:
> class MatchingGrantController < ApplicationController
>
>   active_scaffold do |config|
>
>     # Disable all but Listing and nested functionality
>     config.actions = [:list, :search, :live_search]
>
>   end
> end
>
> But doing so cause AS to try to load the table behind the model. But
> since ALL the fields are delegated there are no table - nor a need for
> one.
>
> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> connection_adapters/abstract_adapter.rb:212:in `log'
> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> connection_adapters/mysql_adapter.rb:320:in `execute'
> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> connection_adapters/mysql_adapter.rb:466:in `columns'
> /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:1276:in `columns'
> /rails/formdir-dev/vendor/plugins/active_scaffold/lib/active_scaffold/
> config/core.rb:101:in `initialize_without_calendar_date_select'
> /rails/formdir-dev/vendor/plugins/active_scaffold/lib/bridges/
> calendar_date_select/lib/as_cds_bridge.rb:5:in `initialize'
> /rails/formdir-dev/vendor/plugins/active_scaffold/lib/
> active_scaffold.rb:57:in `new'
> /rails/formdir-dev/vendor/plugins/active_scaffold/lib/
> active_scaffold.rb:57:in `active_scaffold'
> /rails/formdir-dev/app/controllers/matching_grant_controller.rb:9
>
> /S
>
> On Sep 23, 3:29 am, "[email protected]"
>
> <[email protected]> wrote:
> > Hi,
>
> > you should nt use config.columns = []
> > config.columns is automatically filled with models attributes
>
> > You may add virtual columns: config.columns << :virtual_column
> > You have to extend your model with a method for the virtual_column
>
> > Associations have to be defined in the model
> > If you need associated fields in your list view you may use virtual
> > columms.
>
> > Either use active records delegate inside of your model or do it on
> > your own with a self written method.
>
> > --
> > Volker
>
> > On 22 Sep., 00:23, Soren <[email protected]> wrote:
>
> > > Hi,
>
> > > I'm trying to put active scaffold into a controller that does not have
> > > an underlying model.
>
> > > I therefore picked a model that had some of the fields already and
> > > created a new controller like this:
>
> > > class XyzController < ApplicationController
>
> > >   active_scaffold :users do |config|
>
> > >     config.columns = [ ........ ,  :employer1, :employer2 ]
>
> > > Now I need some of the associated fields from another model.
>
> > > The only hint that I got from the API:Core document on the wiki is
> > > that @user.user_group is the format for associated columns.
> > > But when I use that I get:
> > > You have a nil object when you didn't expect it!
> > > The error occurred while evaluating nil.employer1
>
> > > Obviously I'm doing something really wrong - I just can not see what.
>
> > > The associations are working just fine User.find(...).form.employer1
> > > produces the right thing.
>
> > > Just to confirm - the associated models are done with ActiveRecord -
> > > there is no requirement to have an ActiveScaffold controller for both
> > > models ?
--~--~---------~--~----~------------~-------~--~----~
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