image_submit_tag?
Reported by Colin Jones | July 17th, 2008 @ 02:55 AM
image_submit_tag is something I use relatively frequently; not sure if this could be helpful to others for use in an Engines plugin with syntax like we have for image_tag:
image_submit_tag("test.gif", :plugin => 'test_plugin')
I've kind of gone back and forth between 2 solutions: typing out the full path to the image asset (kind of ugly):
image_submit_tag("/plugin_assets/test_plugin/images/test.gif")
and adding the functionality to Rails in the same pattern as Engines' image_tag:
module Engines::RailsExtensions::FormTagHelpers
def self.included(base)
base.class_eval do
alias_method_chain :image_submit_tag, :engine_additions
end
end
def image_submit_tag_with_engine_additions(source, options={})
options.stringify_keys!
if options["plugin"]
source = Engines::RailsExtensions::PublicAssetHelpers.plugin_asset_path(options["plugin"], "images", source)
options.delete("plugin")
end
image_submit_tag_without_engine_additions(source, options)
end
end
::ActionView::Helpers::FormTagHelper.send(:include, Engines::RailsExtensions::FormTagHelpers)
Does this sound something that would be helpful to have in Engines by default, or is it best added on a project-by-project basis?
Comments and changes to this ticket
-
James Adam October 24th, 2008 @ 02:07 AM
- → State changed from new to more_details_needed
It's not something I commonly use (I tend to use buttons rather than these), but if you can provide some tests, I don't see why it wouldn't be useful...
-

Colin Jones October 24th, 2008 @ 05:55 PM
- → Tag changed from image_submit_tag to assets form_tag_helpers image_submit_tag patch
Here's a patch with tests (err... plural if you include a line in the test view). Let me know how it looks.
-

Colin Jones January 6th, 2009 @ 04:48 PM
I went ahead and put this commit on my "baby fork" on Github (http://github.com/trptcolin/engi.... The commit object is here if you want to just cherry-pick it: http://github.com/trptcolin/engi...
Please let me know if I need to do something different (or if something's wrong with this; I see that I'm in there twice since I cherry-picked the commit from a local git branch)---I'm definitely a git noob.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The rails engines plugin itself
