On Martes, 2 de Febrero de 2010 09:01:01 [email protected] escribió:
> Hi,
>
> if you are using current version of activescaffold I would recommend
> to also take a look at using named scopes:
>
> http://wiki.github.com/activescaffold/active_scaffold/api-list
> def named_scopes_for_collection
> end

I'm thinking in rework this like in inherited_resources, with a 
beginning_of_chain method which defaults to active_scaffold_config.model.

Then you can overrride in the controller to use another thing, for example:
def beginning_of_chain
  current_user.partner.users
end

Or override to use named scopes, for example:
def beginning_of_chain
  active_scaffold_config.model.vegetarian.older_than(20)
end

A shorter version, using super:
def beginning_of_chain
  super.vegetarian.older_than(20)
end


>
> --
> Volker
>
> On 1 Feb., 20:29, Brian Cardarella <[email protected]> wrote:
> > @kenny,
> >
> >   Awesome, that worked. Thanks!
> >
> > On Feb 1, 12:51 pm, Kenny Ortmann <[email protected]> wrote:
> > > *****If AS depends upon my route then it might be useless for what I'm
> > > doing AS does not depend on your route... It tries to do nice things
> > > for you depending on your route, but it doesn't have to do those
> > > things.
> > >
> > > Inside of your controller you can specify the conditions for the
> > > records...
> > >
> > > def conditions_for_collection
> > > end
> > >
> > > There is an example
> > > herehttp://wiki.github.com/activescaffold/active_scaffold/api-list
> > >
> > > The way AS is written you can override almost anything that you want so
> > > you should be able to do all of the admin stuff you want using it.  It
> > > might be frustrating at first but once you have it figured out for one
> > > controller you will know how to do it for the rest.
> > >
> > > ~Kenny
> > >
> > > On Mon, Feb 1, 2010 at 11:39 AM, Brian Cardarella 
<[email protected]>wrote:
> > > > Ah, useless is not the best choice of words. I like AS for doing full
> > > > Admin stuff but limiting the scope of the retrievable records has
> > > > been frustrating.
> > > >
> > > > On Feb 1, 12:34 pm, Brian Cardarella <[email protected]> wrote:
> > > > > @kenny
> > > > >
> > > > >    Well, the point is to limit access to a company's set of users
> > > > > for the company admin. This is a trivial thing in Rails and I'm not
> > > > > certain why it has to be so difficult to do in ActiveScaffold.
> > > > >
> > > > >    If AS depends upon my route then it might be useless for what
> > > > > I'm doing.
> > > > >
> > > > > - Brian
> > > > >
> > > > > On Feb 1, 12:24 pm, Kenny Ortmann <[email protected]> wrote:
> > > > > > Well it depends... Active scaffold does some nice things for you
> > > > > > out of
> > > >
> > > > the
> > > >
> > > > > > box...
> > > > > > for instance
> > > > > >
> > > > > > If you are on they users - partners page,
> > > > > >
> > > > > > url/users/5/partners
> > > > > >
> > > > > > and you have active scaffold configured for the partners
> > > > > > controller, it
> > > >
> > > > will
> > > >
> > > > > > try to load only that users partners.
> > > > > >
> > > > > > But if the out of the box stuff does not work the way you want it
> > > > > > to
> > > >
> > > > you can
> > > >
> > > > > > define this method in your controller
> > > > > >
> > > > > > protected
> > > > > > def conditions_for_collection
> > > > > >   conditions = {:partner_id => current_user.id
> > > > > > end
> > > > > >
> > > > > > Your situation is a little different because you have a has_many
> > > > :
> > > > :through
> > > > :
> > > > > > relationship so you might have to tweak the conditions but you
> > > > > > can get
> > > >
> > > > this
> > > >
> > > > > > to work.
> > > > > >
> > > > > > On Mon, Feb 1, 2010 at 11:13 AM, Brian Cardarella <
> > > >
> > > > [email protected]>wrote:
> > > > > > > So I'm trying to replace some Admin stuff with ActiveScaffold.
> > > > > > > For example, I have this in a particular controller:
> > > > > > >
> > > > > > > def index
> > > > > > >   @users = current_user.partner.users
> > > > > > > end
> > > > > > >
> > > > > > > def show
> > > > > > >   @user = current_user.partner.users.find(params[:id])
> > > > > > > end
> > > > > > >
> > > > > > > Is there a way to replicate this behavior in AS? Everything
> > > > > > > I've read points to no, that it will take into consideration
> > > > > > > all records
> > > >
> > > > instead
> > > >
> > > > > > > of a specific portion of records. Thoughts?
> > > > > > >
> > > > > > > - Brian
> > > > > > >
> > > > > > > --
> > > > > > > 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]<activescaffold%2Bun
> > > > > > >subscr...@go oglegroups.com>
> > > >
> > > > <activescaffold%2bunsubscr...@go oglegroups.com>
> > > >
> > > > > > > .
> > > > > > > For more options, visit this group at
> > > > > > >http://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]<activescaffold%2Bunsubscr
> > > >i...@go oglegroups.com> .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/activescaffold?hl=en.

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