Archive for January, 2008

Digital Coach? Im your man.

January 20th, 2008 by pyrat

digital mess

Are you looking for a digital coach? I could be the man you are looking for.

  • Do you want to improve your technology processes?
  • Do you want to learn about what is the new, hot topic right now?
  • Do you want to learn about Social Networking?
  • Do you want to find out about blogs and whether one would suit your business?
  • Do you want to automate some part of your technology strategy such as a backup strategy?
  • Do you want access to email and files on the road?

Dont hesistate to contact me if you want to find out more.

Inline Button To

January 18th, 2008 by pyrat

buttons

Happy New Year. I have been a bit quiet of late as I have moved to Trondheim, Norway and am getting to grips with everything here.

Every wanted to use the button_to helper and need it to display items on the same name as the button?

Like this :

buttons

If you are running rails2 slap this in your config/initializers directory.

 
 module ActionView
    module Helpers
      module UrlHelper
 
        def inline_button_to(name, options = {}, html_options = {})
 
          html_options = html_options.stringify_keys
          convert_boolean_attributes!(html_options, %w( disabled ))
 
          if(other_code = html_options.delete('inline'))
            other_code = " or " + other_code
          end
 
          method_tag = ''
          if (method = html_options.delete('method')) && %w{put delete}.include?(method.to_s)
            method_tag = tag('input', :type => 'hidden', :name => '_method', :value => method.to_s)
          end
 
          form_method = method.to_s == 'post' ? 'post' : 'get'
 
          request_token_tag = ''
          if form_method == 'post' && protect_against_forgery?
            request_token_tag = tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token)
          end
 
          if confirm = html_options.delete("confirm")
            html_options["onclick"] = "return #{confirm_javascript_function(confirm)};"
          end
 
          url = options.is_a?(String) ? options : self.url_for(options)
          name ||= url
 
          html_options.merge!("type" => "submit", "value" => name)
 
 
 
          "<form method=\"#{form_method}\" action=\"#{escape_once url}\" class=\"button-to\"><div>" +
          method_tag + tag("input", html_options) + request_token_tag + other_code + "</div></form>"
        end
 
      end
    end
  end

The you can call:

<%= inline_button_to 'title', url, {:inline => 'what you want in here'}%>

Cheers.