Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

image_button_to

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image_button_to

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Image Button To

Ruby on Rails provides the following helpers:

  • +button_to+

  • +button_to_function+

  • +button_to_remote+

which wrap a form around a +submit_tag+ to easily create buttons pointing to some action.

What Ruby on Rails doesn't provide is a counterpart for +image_submit_tag+. This gem provides that. It basically contains three helpers:

  • +image_button_to+

  • +image_button_to_remote+

  • +image_button_to_function+

== Installation

This gem is provided through Gemcutter so you need to have gem configured to pull gems from Gemcutter.

=== Enabling Gemcutter

A properly configured environment would be like this:

$ gem sources *** CURRENT SOURCES ***

http://gemcutter.org http://gems.rubyforge.org/ http://gems.github.com

If you don't have http://gemcutter.org in your sources then you need to add. I know two ways to do. One is installing Gemcutter and running gem tumble:

$ sudo gem install gemcutter $ gem tumble

Be careful that gem tumble will remove Gemcutter from your repositories if it's already there.

The other way is by hand like this:

$ gem source -a http://gemcutter.org

I'm not sure if there's any difference. I think there isn't one.

=== Installing image_button_to by hand

It's simple a matter of running:

$ gem install image_button_to

and that's it. Let me know if something breaks.

=== Installing through your Ruby on Rails project

In the +environment.rb+ file of your Ruby on Rails project you'll have some commented out lines like this:

config.gem "bj"

config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"

config.gem "sqlite3-ruby", :lib => "sqlite3"

config.gem "aws-s3", :lib => "aws/s3"

After those you can just add

config.gem "image_button_to"

and then run

$ rake gems:install

and you'll get this and all the gems your Rails project need installed. Configuring your Rails project like that is something you'll need anyway, so this is my recommended way.

== Using the helpers

Be sure to have you Rails project properly configured to load this gem like it's explained in the previous section, in "Installing through your Ruby on Rails project". After that, using each of the methods is equivalent to using the non-image provided by Ruby on Rails, but passing the path to the image instead of the text.

The path to the image is treated in the same way image_submit_tags treat it (appending "images/" and whatnot). Some examples from http://isitsciencefiction.com (where this code was born):

<%= image_button_to "yes-up.png", vote_up_item_url(:id => @item.id) %> <%= image_button_to "no-up.png", vote_down_item_url(:id => @item.id) %> <%= image_button_to_remote "yes-up-small.png", :update => item.slug, :url => vote_up_item_url(:id => item.id) %> <%= image_button_to_remote "no-up-small.png", :update => item.slug, :url => vote_down_item_url(:id => item.id) %>

Check the documentation for image_button_tag and button_to, this is just a merge.

== Documentation

Up to date documentation should be automatically generated on http://rdoc.info/projects/pupeno/image_button_to

== Copyright

Copyright (c) 2009 José Pablo Fernández Silva. See LICENSE for details.

FAQs

Package last updated on 24 Nov 2009

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc