When in doubt, use ".inspect" liberally to find your way around;
&this.inspect or #{this.inspect} should give you a clear Ruby view of what
"this" is at that moment. this_parent is not reflecting a database
relationship, but a relationship of enclosure during computing the view -
see the DRYML reference on this_field and this_parent
<http://hobocentral.net/manual/dryml-guide#thisfield-and-thisparent>.
Apologies, my suggestion of the #{...} syntax versus the &... syntax might
very well have been ill-advised, leading you down on a path of unnecessarly
confusion, just ignore it.
The core of my suggestion was that instead of going top-down, trying to
teach <view> itself to display an avatar, go instead bottom-up: start with
a simple <img src="..."> tag and customize that to display the avatar image
properly, then once you succeeded at that, then you might want to wrap
those customizations into a tag for re-use. and eventually, you might,
indeed, want to extend/customize <view> for the class you are working with
to include displaying the avatar.
That tag you show looks very close to what the intention of my suggestion
was, so if that works, then you're done, so no need to pursue the #{...}
syntax any further.
So, now, as you say that <avater> tag works in the user card, and <avatar
with="&this.user"/> works in the comment card - then what remains to be the
problem, what is missing?
2015. augusztus 1., szombat 17:47:58 UTC+2 időpontban Nathan Peters a
következőt írta:
>
> Thanks for the response but that doesn't seem to work for me. In the
> <tasker-view>, #{this.avatar.image_url} gives me: undefined method `avatar'
> for nil:NilClass.
>
> #{this} shows the name of the tasker (User class), but I don't think it is
> the User object because #{this_parent} Just shows me the name of the
> project name.
>
> I do have a tag definition per Tim:
>
> <def tag="avatar" attrs="size">
> <% size ||= "normal" %>
> <div class="avatar">
> <img src="&this.avatar.url(size.to_sym)" />
> </div>
> </def>
>
> And the definition in the User model:
>
> has_attached_file :avatar,
> :styles => { :normal => "48x48>", :small => "36x36>" },
> :default_style => :normal,
> :default_url => "/images/user-avatar-:style.png",
> :url => "/system/:class/:attachment/:id/:basename-:style.:extension"
> validates_attachment_content_type :avatar, :content_type => ["image/jpg",
> "image/jpeg", "image/png", "image/gif"]
>
>
>
> And this works as <avatar/> in the user card. I also have comments (owned
> by user) and I can make it work in the comment card with <avatar
> with="&this.user"/>.
>
> I also referenced the tag definition and tried: #{this.avatar.url}, but
> that just gets me: undefined method `avatar' for nil:NilClass
>
> It's throwing me off because <view:avatar/> is accessing the avatar
> definition in the model, and correctly pulling in the full URL. So <view>
> is smart enough the figure out what model to access. That makes one of us
> lol.
>
> One thing that may be complicating things is that in my app a project is
> owned by a user, but is associated with another User as tasker. This is
> working in my permissions and lifecycle flow but may be adding some
> complications since I am not always looking for the owner of a record, but
> for the belongs_to association that is pointing to another User (the
> tasker)
>
> Thanks again,
> Nathan
>
> On July 31, 2015 6:39:15 PM CDT, HuBandiT <[email protected] <javascript:>>
> wrote:
>>
>> I would start with something like <img src="#{this.avatar.image_url}"/>
>> (if assuming "image" is the name of your paperclip attachment). Then
>> decorate that with bootstrap styles/classes or other CSS styling.
>>
>> Once you are satisfied, you probably will want to move it into a tag
>> definition to that you can reuse it other places; whis is very simple:
>>
>> <def tag="avatar">
>> <img src="#{this.avatar.image_url}" whatever="other"
>> customizations="you" need="here"/>
>> </def>
>>
>> there, now you have a handy <avatar/> tag, now just switch to that in
>> your table-plus invocation:
>>
>> <table-plus: project fields="this, tasker, state, created_at">
>> <empty-message:>No projects match your criteria</empty-message:>
>> <tasker-view:><view/><avatar/></tasker-view:>
>> <controls:>
>> <transition-buttons/>
>> </controls:>
>> </table-plus>
>>
>> and that's pretty much it I think.
>>
>> 2015. július 31., péntek 19:09:55 UTC+2 időpontban Nathan Peters a
>> következőt írta:
>>>
>>> I have partially answered my own questions.
>>>
>>> Regarding image alignment in the <content-header> on the user show page.
>>> I am just using CSS to float the image left. And I'll need to customize
>>> anyway so CSS is probably the way to go.
>>>
>>> I can almost make the link to the Paperclip attachment work but I am
>>> missing something.
>>>
>>> <table-plus: project fields="this, tasker, state, created_at">
>>> <empty-message:>No projects match your criteria</empty-message:>
>>> <tasker-view:><view/><view:avatar if-blank=""/></tasker-view:>
>>> <controls:>
>>> <transition-buttons/>
>>> </controls:>
>>> </table-plus>
>>>
>>> This code gives me the name of the "tasker" (what would be there
>>> normally) and a text of the image attachment path called avatar. I added
>>> the if-blank to prevent anything being displayed if no attachment is
>>> available.
>>>
>>> But I can't seem to figure out how to convert the output of
>>> <view:avatar> to an image link. I know <view> wraps different kinds of
>>> content. Maybe there is a way to force it to handle images?
>>>
>>
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.