Thanks.

This I get :)   {|e| e.symbol}



On Sun, Jul 12, 2009 at 8:23 AM, Nathan Weizenbaum<[email protected]> wrote:
> That's a Rails-specific idiom (although it's also available in Ruby 1.9)
> that means {|e| e.symbol}.
>
> On Sun, Jul 12, 2009 at 11:17 AM, Noel <[email protected]> wrote:
>>
>> Thanks Nathan,
>>
>> This works and it's simple.
>> just for my understanding, i'm still a ruby n00b, what does this part mean
>>
>> (&:symbol)
>>
>>
>>
>> -Noel
>>
>>
>> On Sat, Jul 11, 2009 at 10:34 PM, Nathan Weizenbaum<[email protected]>
>> wrote:
>> > Yes, Steve is right: this is the expected and desired behavior. A line
>> > in
>> > source code pretty much means at least one line in output. If you want
>> > them
>> > concatenated without whitespace, you don't want a partial, you want a
>> > helper. Or just item.footnotes.map(&:symbol).join("").
>> >
>> > On Sat, Jul 11, 2009 at 9:55 PM, Noel <[email protected]> wrote:
>> >>
>> >> I got it to work, but still got the newline/
>> >>
>> >> had to add this in application controller
>> >>
>> >>    public :render_to_string
>> >>
>> >>
>> >>
>> >> <td>
>> >>                  tincidunt eu
>> >>                  <span class="footnote_symbols">
>> >>                    3
>> >>                    5
>> >>                  </span>
>> >>                </td>
>> >>
>> >> On Sat, Jul 11, 2009 at 6:50 PM, Noel<[email protected]> wrote:
>> >> > Well, I still get an error
>> >> >
>> >> > protected method `render_to_string' called for
>> >> > #<RestaurantsController:0x23e207c>
>> >> >
>> >> > Here's all the code
>> >> >
>> >> > http://pastie.org/private/rmow8bgpzv9btou0yqjg
>> >> >
>> >> > The reason I don't do this concatenation in the controller is that
>> >> > this is several partials deep.
>> >> > controller gets restaurants and eager loads other models. restaurants
>> >> > -> menus ... footnotes
>> >> >
>> >> > item :has_many footnotes
>> >> >
>> >> > The simplest solution is probably to just iterate thought
>> >> > item.footnotes in the _item partial.  Just seemed to me that using a
>> >> > partial was the best practice.
>> >> >
>> >> >
>> >> >
>> >> > On Sat, Jul 11, 2009 at 6:19 PM, s.ross<[email protected]> wrote:
>> >> >>
>> >> >> Noel--
>> >> >>
>> >> >> Can you be more specific than "didn't work"? Really, it looks like
>> >> >> what you've described is just taking two (or possibly) scalars from
>> >> >> the database and concatenating them as strings. If that's the case,
>> >> >> why not just do it in the controller instead of having a separate
>> >> >> partial?
>> >> >>
>> >> >> WRT why Haml adds the newline: I dunno, it always has added one when
>> >> >> you have a newline in your code. Rendering a partial that contains a
>> >> >> single line in a loop would suggest that the newline is appropriate.
>> >> >> I'm not sure that erb is doing the right thing.
>> >> >>
>> >> >> On Jul 11, 2009, at 5:50 PM, Noel wrote:
>> >> >>
>> >> >>>
>> >> >>> tried this in the helper and didn't work.
>> >> >>>
>> >> >>> Even if it did I don't think this work around is the way to go.
>> >> >>>
>> >> >>> Why does HAML adds the newline?
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> On Sat, Jul 11, 2009 at 4:09 PM, s.ross<[email protected]> wrote:
>> >> >>>>
>> >> >>>> My bad. It's in ActionController::Base.
>> >> >>>>
>> >> >>>> Try
>> >> >>>>
>> >> >>>> controller.render_to_string(:partial => 'the_partial', :object =>
>> >> >>>> number)
>> >> >>>>
>> >> >>>> I know somewhere I had to do this... can't dig up the code right
>> >> >>>> now.
>> >> >>>>
>> >> >>>>
>> >> >>>> On Jul 11, 2009, at 3:58 PM, Noel wrote:
>> >> >>>>
>> >> >>>>>
>> >> >>>>> y, put it in application_helper.rb
>> >> >>>>>
>> >> >>>>>
>> >> >>>>> On Sat, Jul 11, 2009 at 3:43 PM, Michael
>> >> >>>>> Hollins<[email protected]>
>> >> >>>>> wrote:
>> >> >>>>>>
>> >> >>>>>>
>> >> >>>>>> Did you define the helper in application_helper.rb?
>> >> >>>>>>
>> >> >>>>>> render_to_string should be available there.
>> >> >>>>>>
>> >> >>>>>>
>> >> >>>>>> On 12/07/2009, at 8:26 AM, Noel <[email protected]> wrote:
>> >> >>>>>>
>> >> >>>>>>>
>> >> >>>>>>> I don't know how to implement this
>> >> >>>>>>>
>> >> >>>>>>> render_to_string is undefined.
>> >> >>>>>>>
>> >> >>>>>>> also I am guessing I have to pass in the item so that i can get
>> >> >>>>>>> all
>> >> >>>>>>> it's footnotes
>> >> >>>>>>>
>> >> >>>>>>>
>> >> >>>>>>>
>> >> >>>>>>> On Sat, Jul 11, 2009 at 3:14 PM, s.ross<[email protected]>
>> >> >>>>>>> wrote:
>> >> >>>>>>>> I suspect this is a side effect of Haml putting elements on
>> >> >>>>>>>> different lines.
>> >> >>>>>>>> So because the partial is called twice, Haml inserts a
>> >> >>>>>>>> newline.
>> >> >>>>>>>> Everything
>> >> >>>>>>>> in the generated HTML points to this. Possibly a way to get
>> >> >>>>>>>> the
>> >> >>>>>>>> desired
>> >> >>>>>>>> effect is to use a helper:
>> >> >>>>>>>> def whats_the_number?
>> >> >>>>>>>>   the_number = ""
>> >> >>>>>>>>   numbers.each do |number|
>> >> >>>>>>>>     the_number += render_to_string(:partial => 'the_partial')
>> >> >>>>>>>>   end
>> >> >>>>>>>>   the_number
>> >> >>>>>>>> end
>> >> >>>>>>>> Then in the view:
>> >> >>>>>>>> = whats_the_number?
>> >> >>>>>>>> Am I getting close (extra cute method names, etc., aside)?
>> >> >>>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>>> On Jul 11, 2009, at 1:56 PM, Nathan Weizenbaum wrote:
>> >> >>>>>>>>
>> >> >>>>>>>> How are you calling the partial?
>> >> >>>>>>>>
>> >> >>>>>>>> On Sat, Jul 11, 2009 at 4:49 PM, Noel <[email protected]>
>> >> >>>>>>>> wrote:
>> >> >>>>>>>>>
>> >> >>>>>>>>> It prints twice bec the partial is called twice. Once for
>> >> >>>>>>>>> each
>> >> >>>>>>>>> symbol.
>> >> >>>>>>>>> There is no concat that I know of.
>> >> >>>>>>>>>
>> >> >>>>>>>>> Sent from my iPhone
>> >> >>>>>>>>> On Jul 11, 2009, at 12:56 PM, Nathan Weizenbaum
>> >> >>>>>>>>> <[email protected]
>> >> >>>>>>>>> >
>> >> >>>>>>>>> wrote:
>> >> >>>>>>>>>
>> >> >>>>>>>>> That's even more bizarre. The only thing I can guess is that
>> >> >>>>>>>>> both
>> >> >>>>>>>>> Haml and
>> >> >>>>>>>>> ERB are printing the thing twice. Is it possible that
>> >> >>>>>>>>> something in
>> >> >>>>>>>>> there is
>> >> >>>>>>>>> calling concat at some point?
>> >> >>>>>>>>>
>> >> >>>>>>>>> On Sat, Jul 11, 2009 at 2:45 PM, Noel <[email protected]>
>> >> >>>>>>>>> wrote:
>> >> >>>>>>>>>>
>> >> >>>>>>>>>> in erb i get
>> >> >>>>>>>>>>
>> >> >>>>>>>>>> <td>
>> >> >>>>>>>>>>                  tincidunt eu
>> >> >>>>>>>>>>                  <span class="footnote_symbols">
>> >> >>>>>>>>>>                    StringString
>> >> >>>>>>>>>>                  </span>
>> >> >>>>>>>>>>                </td>
>> >> >>>>>>>>>>
>> >> >>>>>>>>>> in HAML I get
>> >> >>>>>>>>>>
>> >> >>>>>>>>>> <td>
>> >> >>>>>>>>>>                  tincidunt eu
>> >> >>>>>>>>>>                  <span class="footnote_symbols">
>> >> >>>>>>>>>>                    String
>> >> >>>>>>>>>>                    String
>> >> >>>>>>>>>>                  </span>
>> >> >>>>>>>>>>                </td>
>> >> >>>>>>>>>>
>> >> >>>>>>>>>> Same extra line.
>> >> >>>>>>>>>> String
>> >> >>>>>>>>>> String
>> >> >>>>>>>>>>
>> >> >>>>>>>>>> vs
>> >> >>>>>>>>>>
>> >> >>>>>>>>>> StringString
>> >> >>>>>>>>>>
>> >> >>>>>>>>>>
>> >> >>>>>>>>>> On Sat, Jul 11, 2009 at 10:46 AM, Nathan
>> >> >>>>>>>>>> Weizenbaum<[email protected]
>> >> >>>>>>>>>>>
>> >> >>>>>>>>>> wrote:
>> >> >>>>>>>>>>> If that's what you get, it's not just a string. I don't
>> >> >>>>>>>>>>> know
>> >> >>>>>>>>>>> what it is
>> >> >>>>>>>>>>> if
>> >> >>>>>>>>>>> it produces that sort of inspect output. What happens if
>> >> >>>>>>>>>>> you
>> >> >>>>>>>>>>> call
>> >> >>>>>>>>>>> .class?
>> >> >>>>>>>>>>>
>> >> >>>>>>>>>>> On Sat, Jul 11, 2009 at 12:24 PM, Noel <[email protected]>
>> >> >>>>>>>>>>> wrote:
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>> - Yes, removing the h yields the same result
>> >> >>>>>>>>>>>> - Not sure about the haml executable, have to look up how
>> >> >>>>>>>>>>>> to do
>> >> >>>>>>>>>>>> that
>> >> >>>>>>>>>>>> - inspect produced this in erb
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>> <td>
>> >> >>>>>>>>>>>>                  tincidunt eu
>> >> >>>>>>>>>>>>                  <span class="footnote_symbols">
>> >> >>>>>>>>>>>>                    "3""5"
>> >> >>>>>>>>>>>>                  </span>
>> >> >>>>>>>>>>>>                </td>
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>> and this in HAML
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>> <td>
>> >> >>>>>>>>>>>>                  tincidunt eu
>> >> >>>>>>>>>>>>                  <span class="footnote_symbols">
>> >> >>>>>>>>>>>>                    "3"
>> >> >>>>>>>>>>>>                    "5"
>> >> >>>>>>>>>>>>                  </span>
>> >> >>>>>>>>>>>>                </td>
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>> On Sat, Jul 11, 2009 at 6:15 AM, Nathan
>> >> >>>>>>>>>>>> Weizenbaum<[email protected]
>> >> >>>>>>>>>>>>>
>> >> >>>>>>>>>>>> wrote:
>> >> >>>>>>>>>>>>> I honestly have no idea what's going on here. Does it
>> >> >>>>>>>>>>>>> still
>> >> >>>>>>>>>>>>> happen
>> >> >>>>>>>>>>>>> if
>> >> >>>>>>>>>>>>> you
>> >> >>>>>>>>>>>>> remove the #h call? Does it happen from the haml
>> >> >>>>>>>>>>>>> executable?
>> >> >>>>>>>>>>>>> What do
>> >> >>>>>>>>>>>>> you
>> >> >>>>>>>>>>>>> get
>> >> >>>>>>>>>>>>> if you do = h footnote_symbol.symbol.inspect?
>> >> >>>>>>>>>>>>>
>> >> >>>>>>>>>>>>> On Sat, Jul 11, 2009 at 2:16 AM, Noel
>> >> >>>>>>>>>>>>> <[email protected]>
>> >> >>>>>>>>>>>>> wrote:
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>> oh sorry, symbol is a string
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>> Erb renders this (as copied from safari web inspector)
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>> <td>
>> >> >>>>>>>>>>>>>>                  tincidunt eu
>> >> >>>>>>>>>>>>>>                  <span class="footnote_symbols">
>> >> >>>>>>>>>>>>>>                    35
>> >> >>>>>>>>>>>>>>                  </span>
>> >> >>>>>>>>>>>>>>                </td>
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>> HAML renders this
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>> <td>
>> >> >>>>>>>>>>>>>>                  tincidunt eu
>> >> >>>>>>>>>>>>>>                  <span class="footnote_symbols">
>> >> >>>>>>>>>>>>>>                    3
>> >> >>>>>>>>>>>>>>                    5
>> >> >>>>>>>>>>>>>>                  </span>
>> >> >>>>>>>>>>>>>>                </td>
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>> Let me know if you need further clarification.
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>> -Noel
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>> On Fri, Jul 10, 2009 at 10:33 PM, Nathan
>> >> >>>>>>>>>>>>>> Weizenbaum<[email protected]>
>> >> >>>>>>>>>>>>>> wrote:
>> >> >>>>>>>>>>>>>>> I'm sorry, I'm still not getting it. Is
>> >> >>>>>>>>>>>>>>> footnote_symbol.symbol a
>> >> >>>>>>>>>>>>>>> string?
>> >> >>>>>>>>>>>>>>> An
>> >> >>>>>>>>>>>>>>> array? What's the actual HTML output of Haml vs. ERB?
>> >> >>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>> On Fri, Jul 10, 2009 at 3:34 PM, Noel
>> >> >>>>>>>>>>>>>>> <[email protected]>
>> >> >>>>>>>>>>>>>>> wrote:
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> Here is an example:
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> HAML view has this
>> >> >>>>>>>>>>>>>>>> =h footnote_symbol.symbol
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> which produces this:
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> http://skitch.com/noelgomez/ba821
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> I am talking about the space between the 4 and the 3
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> In the DB the symbols are single characters.
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> Here is the same using erb which just prints 43
>> >> >>>>>>>>>>>>>>>> <%=h footnote_symbol.symbol %>
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> http://skitch.com/noelgomez/ba826
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> Not sure if I am doing something wrong, but odd that
>> >> >>>>>>>>>>>>>>>> erb
>> >> >>>>>>>>>>>>>>>> does
>> >> >>>>>>>>>>>>>>>> what I
>> >> >>>>>>>>>>>>>>>> expect.
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>> On Fri, Jul 10, 2009 at 11:27 AM, Nathan
>> >> >>>>>>>>>>>>>>>> Weizenbaum<[email protected]>
>> >> >>>>>>>>>>>>>>>> wrote:
>> >> >>>>>>>>>>>>>>>>> I'm not entirely sure what you mean. What's the exact
>> >> >>>>>>>>>>>>>>>>> Ruby
>> >> >>>>>>>>>>>>>>>>> value
>> >> >>>>>>>>>>>>>>>>> of
>> >> >>>>>>>>>>>>>>>>> footnote_symbol.symbol?
>> >> >>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>> On Fri, Jul 10, 2009 at 9:08 AM, Noel
>> >> >>>>>>>>>>>>>>>>> <[email protected]
>> >> >>>>>>>>>>>>>>>>> >
>> >> >>>>>>>>>>>>>>>>> wrote:
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> I have a very simple partial
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> = h footnote_symbol.symbol
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> I verified the length of symbol to be 1.  My dev
>> >> >>>>>>>>>>>>>>>>>> data
>> >> >>>>>>>>>>>>>>>>>> is
>> >> >>>>>>>>>>>>>>>>>> (*,1,2,3,4...)
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> when this renders as an example I get
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> 2 5
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> but I was expecting
>> >> >>>>>>>>>>>>>>>>>> 25
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> if I change the partial to erb instead of haml I do
>> >> >>>>>>>>>>>>>>>>>> get
>> >> >>>>>>>>>>>>>>>>>> 25.
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> I am using haml (2.2.0)
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> Any ideas where the extra space is coming from?
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>> -Noel
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>>
>> >> >>>>>>>>>>>>>
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>
>> >> >>>>>>>>>>>
>> >> >>>>>>>>>>>>
>> >> >>>>>>>>>>>
>> >> >>>>>>>>>>
>> >> >>>>>>>>>>
>> >> >>>>>>>>>
>> >> >>>>>>>>>
>> >> >>>>>>>>>
>> >> >>>>>>>>>
>> >> >>>>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>>
>> >> >>>>>>>>
>> >> >>>>>>
>> >> >>>>>>>
>> >> >>>>>>
>> >> >>>>>
>> >> >>>>>>
>> >> >>>>
>> >> >>>>
>> >> >>>>>
>> >> >>>>
>> >> >>>
>> >> >>> >
>> >> >>
>> >> >>
>> >> >> >>
>> >> >>
>> >> >
>> >>
>> >>
>> >
>> >
>> > >
>> >
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" 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/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to