Not only do you have to set the "owner" field to be viewable, you also
have to set the "name" field of the linked user to be viewable as
well.

Sometimes permissions are tricky to get right.   Let me know if you
still have problems.

Bryan

On Mon, Mar 8, 2010 at 10:07 AM, Mark Jones <[email protected]> wrote:
> Hi,
>
> Within My Application I have a 'comments' section, (like a forum)
> where the owner of a 'task' can comment and an administrator can
> respond.
>
> This uses a table-plus:
>
>  <table-plus:comments fields="this, owner" force-all>
>    <empty-message:>This application currently has no comments.</empty-
> message:>
>        <header: replace/>
>  </table-plus>
>
> Each comment has an owner within comments.rb:
>
>   belongs_to :owner, :class_name => "User", :creator => true
>
> If I logon as administrator this page shows up fine and I get a table
> which shows the comment title and the owner name with a link to the
> owners user page.
>
> However if the owner then logs on and goes to this page I get:
>
>    ActionView::TemplateError (view of non-viewable field 'owner' of
> comment:30) on line #22 of app/views/versions/show.dryml:
>
> This is because in my user model I have restricted users to only owner
> or administrator:
>  def view_permitted?(field)
>        return true if self == acting_user || acting_user.administrator? ||
> self.new_record?
>        return true if (field.to_s == "password" || field.to_s ==
> "password_confirmation")
>  end
>
> Any ideas how I can get around this and present the username of the
> admin who put the comment but not have a link to it? i.e. view only
>
> I have tried:
>
> 1) adding  '|| field.to_s == "owner" ' to the view_permitted
> 2) adding  def owner_view_permitted? true end
>
> Thanks
>
> Mark
>
> --
> 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.
>
>

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

Reply via email to