Hi
On Sun, Jun 12, 2016, at 01:51, Rynn Steinbolt wrote:
> im currently trying to implement a form with several buttons, and my
> solution for that was to make a full form for each of the 5 buttons.
> thats extremely repetitive, so i wanted to generate the forms with a
> helper function that i define myself, but i cant make it work.
>
> my form method:
>
> module ApplicationHelper
> def raw_datum_new_helper(status)
>
> form_for(@raw_datum) do |f|
> if @raw_datum.errors.any?
> "<div id='error_explanation'>"
> "<h2>#{pluralize(@raw_datum.errors.count, "error"})prohibited
> this raw_datum from being saved:</h2>"
> "<ul>"
> @raw_datum.errors.full_messages.each do |msg|
> "<li>#{msg}</li>
> #{end}
> </ul>
> </div>"
> <% end %>
>
> "<div class='field'>"
> #{f.hidden_field :timestamp, :value => Time.now.to_s[0,16]
> f.hidden_field :status, :value => status}
> </div><div class='actions'>"
> f.submit :value => status
> "</div>"
> end
>
> end
> end
>
Rails helper is normal ruby method so you can't write it like erb. There
also a few syntax errors.
You'll be better off writing partial instead of helper.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1465664410.1338658.634750073.0BDB0E52%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment