table/table-plus not working nicely with view_permitted?

3 views
Skip to first unread message

craig...@gmail.com

unread,
Jan 29, 2009, 8:54:32 PM1/29/09
to Hobo Users
I am running into a problem on edge hobo where the table/table-plus
tags are trying to render rows for every item in the collection
regardless of whether or not the current user has permissions to view
it. Along with that, if the current user does not have permission to
view the item it will try to render a row but will run into errors
when trying to display the individual fields for the item for all
fields besides 'this'.

Here is a simple app to recreate the problem:

1. Create an edge hobo app
2. Create a post model with a title:string and is_private:boolean
3. add belongs_to :user on the post model
4. add has_many :posts to the user model
5. change view_permitted? of post to be - !is_private || owner_is?
(acting_user) || acting_user.administrator?
6. migrate everything
7. create some posts, some of the as with is private checked and
others not
8. create post/index.dryml and put this in it

<index-page>
<collection: replace>
<table without-header fields="this, draft, created_at" />
</collection:>
</index-page>

9. View the index of posts as a guest and you should start seeing
errors

Any ideas on this? Any one else having this problem?

Thanks,

Craig

kevinpfromnm

unread,
Jan 29, 2009, 10:20:56 PM1/29/09
to Hobo Users
If you're going to have a collection, usually you preload the
collection and filter out what you don't want to reduce memory
overhead for one and to ensure accurate pagination for two. If those
aren't a concern, add an if condition on the row checking for
permission will just not display those items for which permission is
lacking.

For example:
<table>
<tr: if="&this.view_permitted?(field)" />
</table>

Though, most times at least one of the first two conditions I
mentioned applies so you filter what you load.

I actually tried mostly the same thing before tom pointed that out to
me about the pagination.

On Jan 29, 6:54 pm, "craigku...@gmail.com" <craigku...@gmail.com>
wrote:

craig...@gmail.com

unread,
Feb 2, 2009, 5:48:01 PM2/2/09
to Hobo Users
Good call.

Thanks,

Craig
Reply all
Reply to author
Forward
0 new messages