rubyonrailsin

A Ruby and Rails talk

Saturday, March 20, 2010


[Rails] Re: Displaying an image in a Rails form_for

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Hi Colin,

> I think that should be
> <%= image_tag "DownArrow.jpg" %>

I tried that once merely changing f.image to f.image_tag, which I had
tried earlier.
Happily, then I noticed that you also omitted the "f.". So you were
spot-on! Great job!

I superficially thought that all the things in the block had to be
f.xxx or generated html would be out of order, or something. Now I
realize the html is generated in the order its created, regardless of
what method is invoked to create it. At least, that's how I'm
thinking about it now.

BTW, the rest of that code in that section is:
<p>
<%= f.label :vendor %><br />
<%= f.text_field :vendor %>
<%= image_tag "DownArrow.jpg" %>
<br>
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v| v.nickname }),
{:multiple => true} %>
</p>

So I no longer need the sidebar I could never get working. The
select_tag was what I really wanted, but I didn't go about seeking
properly for a week. Whew, I'm glad that's behind me.

Best wishes,
Richard

On Mar 20, 5:09 pm, Colin Law <clan...@googlemail.com> wrote:
> On 20 March 2010 18:29, RichardOnRails
>
> <RichardDummyMailbox58...@uscomputergurus.com> wrote:
> > Hi,
>
> > I've got a public\images\DownArrow.jpg
> > and app\views\expenses\new.html.erb that want to present this image in
> > the following context:
>
> >  <p>
> >    <%= f.label :vendor %><br />
> >    <%= f.text_field :vendor %>
> >    <%= f.image "DownArrow.jpg" %>
>
> I think that should be
> <%= image_tag "DownArrow.jpg" %>
>
> Colin
>
> >    <br>
> >    <%= select_tag "test",
> >          options_for_select(@current_vendors.collect { |v| v.nickname }),
> >          {:multiple => true} %>
> >  </p>
>
> > But Rails gushes the unforgiving response:
> > undefined method `image' for #<ActionView::Helpers::FormBuilder:
> > 0x48194e0>
>
> > I couldn't find anything helpful in:
> > --http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html
> > --http://api.rubyonrails.org/http://api.rubyonrails.org/
> > -- Google
>
> > Any ideas?
>
> > Thanks in Advance,
> > Richard
>
> > --
> > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive