for some reason i was completely failing to get my head round the
controller solution - but finally it's clicked. so here's a working
version for CallController that only lists only owned calls for
user.role == probation....
def index
if current_user.role != "probation"
hobo_index Call.apply_scopes(:search =>
[params[:search], :name],
:order_by =>
parse_sort_param(:user, :name, :created_at),
:user_is => params[:user] || current_user)
else
hobo_index Call.user_is(current_user).apply_scopes(
:search => [params[:search], :name],
:order_by =>
parse_sort_param(:user, :name, :created_at))
end
end
thanks a lot kevin and everyone else for your input
paul
On 9 July, 23:09, kevinpfromnm <[email protected]> wrote:
> or in the controller
>
> On Jul 8, 2:14 pm, storitel <[email protected]> wrote:
>
> > thanks, kevin - that works....
>
> > *but* because <table-plus> still thinks it has all the rows, not just
> > the filtered ones, pagination kicks in.
>
> > i guess i need to solve this at the scope/association level after all :
> > (
>
> > On 7 July, 22:51, kevinpfromnm <[email protected]> wrote:
>
> > > try
> > > <tr: replace>
> > > <tr restore if="&can_view?(this)" />
> > > </tr:>
>
> > > On Jul 7, 3:39 pm, storitel <[email protected]> wrote:
>
> > > > i did try that, but
>
> > > > attribute 'if' is not allowed on parameter tags (<tr:>) -- at app/
> > > > views/contacts/show.dryml:64
>
> > > > so then i messed around with
>
> > > > <tr:>
> > > > <if test="&can_view?(this)">
> > > > hello
> > > > </if>
> > > > </tr:>
>
> > > > the result is I get hello repeated as many times as there are viewable
> > > > records, *followed* by the header row of the table-plus. definitely
> > > > not expected behaviour.
>
> > > > On 7 July, 18:54, kevinpfromnm <[email protected]> wrote:
>
> > > > > no, you want something like <tr: if="&can_view?(this)" />
>
> > > > > On Jul 4, 1:00 pm, storitel <[email protected]> wrote:
>
> > > > > > Sstill struggling here....can't find any examples of can_view?
> > > > > > anywhere...
>
> > > > > > from what i can work out, given that <table-plus> merges <table> i
> > > > > > think it *should* be ok to do the following...
>
> > > > > > <table-plus with="&[email protected]" fields="created_at,
> > > > > > this">
> > > > > > <tr:><view if="&can_view?"/></tr:>
> > > > > > <header: replace/>
> > > > > > </table-plus>
>
> > > > > > but it leads to weird output - the viewable row(s) get rendered
> > > > > > *above* the <table-plus> header row, and there are no data rows in
> > > > > > the
> > > > > > table-plus???
>
> > > > > > On 3 July, 14:10, storitel <[email protected]> wrote:
>
> > > > > > > Thank you very much for this - I've now fixed the field-level
> > > > > > > issue as
> > > > > > > kevin suggested - the following skips the count field if not
> > > > > > > viewable...
>
> > > > > > > <table-plus fields="this, calls.count, user">
> > > > > > > <calls-count-heading:>Calls</calls-count-heading:>
> > > > > > > <calls-count-view:><view
> > > > > > > if="&can_view?"/></calls-count-view:>
> > > > > > > </table-plus>
>
> > > > > > > could you more specific on how to solve the row-level case? i'm
> > > > > > > struggling to figure out the syntax for using can_view? to get
> > > > > > > table-
> > > > > > > plus to skip rows that are not viewable...
>
> > > > > > > also i'd be interested to know how to do the viewable check in the
> > > > > > > association itself?
>
> > > > > > > sorry if these questions seem basic...
> > > > > > > thanks again
> > > > > > > Paul
>
> > > > > > > On 2 July, 10:12, Bernhard Leicher
> > > > > > > <[email protected]>
> > > > > > > wrote:
>
> > > > > > > > On 1 Jul., 13:40, Matt Jones <[email protected]> wrote:
>
> > > > > > > > > Yep - it's a bug.
>
> > > > > > > > >https://hobo.lighthouseapp.com/projects/8324/tickets/726
>
> > > > > > > > > using can_view?(this) instead will make it work for now.
>
> > > > > > > > Thank you!
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en.