On Feb 18, 6:12 am, "Sergio Cambra .:: entreCables S.L. ::."
<[email protected]> wrote:
> On Miércoles, 17 de Febrero de 2010 20:01:33 Pusillanimous Coward escribió:
>
>
>
> > Two issues with text field helpers:
>
> > 1. Create a helper like
>
> >   def data_column(record)
> >     text_area :record, :data, :cols => 75, :rows => 25, :disabled =>
> > 'disabled'
> >   end
>
> > The data in the text box will be decorated with br tags.
>
> > 2. With the latest download, the helper above will not be called.
>
> > My work-around:
>
> > In active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb,
> > make the following change:
>
> > Replace
>
> >       def active_scaffold_show_text(column, record)
> >         simple_format(get_column_value(record, column))
> >       end
>
> > with
>
> >       def active_scaffold_show_text(column, record)
> >         if override_show_column_ui?(column.column.type)
> >           get_column_value(record, column)
> >         else
> >           simple_format(clean_column_value(record.send(column.name)))
> >         end
> >       end
>
> It has no sense. active_scaffold_show_text is called when
> override_show_column_ui?(column.column.type) returns true, so the if statement
> always will be true and it's the same as:
> def active_scaffold_show_text(column, record)
>   get_column_value(record, column)
> end
>
> And that it's the same as remove that method.
>
> If you want to override the column in show view, use a show override:
> def data_show_column(record)
>
> --
> Sergio Cambra .:: entreCables S.L. ::.
> Mariana Pineda 23, 50.018 Zaragoza
> T) 902 021 404 F) 976 52 98 07 E) [email protected]


You are correct.  I had a mistake in my post.  The behavior of
active_scaffold is different with my change, so please don't dismiss
it.

In the last version of active scaffold that I downloaded in October
2009, the helper

  def data_column(record)
    text_area :record, :data, :cols => 75, :rows => 25, :disabled =>
'disabled'
  end

was called on Show (and List).  With the latest version, it is not.

active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb:

>From October 2009:

      def active_scaffold_show_text(column, record)
        simple_format(get_column_value(record, column))
      end

>From February 2010:

      def active_scaffold_show_text(column, record)
        simple_format(clean_column_value(record.send(column.name)))
      end

The latest active_scaffold_show_text does not call the helper.
Replacing it with the older one DOES call the helper.

In addition, I wanted to fix a separate problem- that when my helper
put the text in a text box, the text was decorated with html.  This
was due to always calling simple_format for text.  So, I further
changed the method to figure out if a helper is being used, and not to
call simple_format in that case.

      def active_scaffold_show_text(column, record)
        if override_show_column_ui?(column.column.type)
          get_column_value(record, column)
        else
          simple_format(clean_column_value(record.send(column.name)))
        end
      end

I hope this helps.

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.

Reply via email to