Archive

Author Archive

Learn to build a Rails app using Heroku and Git

November 8th, 2009 admin No comments

Hi All:

I have recently discover Heroku service for building applications. It is extremely useful and extremely easy to use. It is also based in Git a SCM system which is also revolutionazing the version control systems.

To install Git, we could use this guide located on the progit or also you can see this page which explains how to use textmate with git

We set git configuration:

$ git config --global user.name "Your Name"
$ git config --global user.email youremail@example.com

There is a great Quickstart for using Heroku which I used as a base for this post: http://docs.heroku.com/quickstart

  • Sign in in Heroku
  • Install Heroku gem:
$ sudo gem install heroku
  • Create the local application in your mac: rails myapp
  • Access to the rails app: cd myapp
  • Install git
  • Execute git:  $ git init
  • Do git add:  $ git add .
  • We access to the following command:
    • Do git first commit: $ git commit -m "new app"
    • We open the application, and we start the local server ruby script/server and access to localserver using http://127.0.0.1:3000
    • As usual, we generate a index or home controller. I generally call them dashboard as it is sexy: $ ruby script/generate controller dashboard index
    • We delete the entry page: $ rm public/index.html
    • We modify the config/routes.rb to enter the following route map:
      • We create the heroku application directly on the heroku site from our computer merely using the Heroku’s gem
      • Now the web site will be visible on the following address: http://severe-stone-45.heroku.com. Sustitute the name by the name provided by Heroku and you got it. As the heroku repository is blank when we create the application we need to deploy the code to a specific branch, we deploy the code throuh this instruction
    • $ rake db:create
      db/development.sqlite3 already exists
      map.connect ':controller/:action/:id'
      map.connect ':controller/:action/:id.:format'
      # Enter the route to access to enter the dashboard
       map.root :controller => "dashboard"
      rake db:migrate
      heroku create
      Created http://severe-stone-45.heroku.com/ | git@heroku.com:severe-stone-45.git

      $ git push heroku master

    Categories: Ruby, RubyonRails Tags:

    I have changed to JQuery in Rails

    November 8th, 2009 admin No comments

    jQuery is today the best js library, prototype is a challenger.The reasons why I think this are beautifully illustrated on the following post. To use jQuery in rails install the following plugin:

    ruby script/plugin install http://ennerchi.googlecode.com/svn/trunk/plugins/jrails

    Here is a list of existing functions which are available once we replace prototype+scriptacuolous for the jquery. Hopefully, this support will improve once we approach to Rails 3.

    If you want to use both libraries, you will keep prototype js files, if you plan to use only jquery you could removed them. I particularly think that seems you have decided to use jquery there is few reasons to keep them.

    Also, there are two ways to use jquery, I just found this interesting article which speak about a different way to use jquery, not using jrails but instead in a more unobstrusive way. Interesting point of view.
    http://www.notgeeklycorrect.com/english/2009/05/18/beginners-guide-to-jquery-ruby-on-rails/

    Kind regards and good weekend

    Jruby on Rails on SAP NetWeaver Studio

    August 31st, 2009 admin No comments

    Many of you have already heard about JRuby and its Rails implementation called JRuby on Rails, for those who do not I would recommend to read the following articles:

    • JRuby: The power of Java and Ruby
    • This article which clearly explain the basics is about JRuby.
    • This article from Java World gives an overview JRuby on Rails. 
    • Additionally, there is another article from Developer.com which runs over the first steps on creating and deploying a JRuby on Rails application.

    Ok, once we are all on the same page, I am going to make a more detailed overview, on how to develop a JRuby on Rails project using SAP NetWeaver Studio. Just to mention that I am currently using version 7.1 SP6 which is built over Eclipse 3.3.0 and Java 5 Sdk.  I know it is a little bit more advanced than the most mayority of current SAP projects, which are probably using SAP NetWeaver Studio 7.0 but well, it is what I have.

    There is an existing one-click installer from JRuby on Rails suitable for testing for a company called bitnami, which has a very interesting market proposition. I am myself I use RubyStack with no futher problems.
    However, I have done manually to fully understand the development architecture. So let se which are the steps to perform:

    1) Download JRuby: As first step, we are going to download latest version of JRuby from JRuby site. In this case is JRuby 1.1.4, which can be download from its repositories. Select what it suits for your operating system.

    While you wait it to download, if you like you can read something or you want watch a video related to JRuby on Rails, plese the following video:

    Ok, now it is already download, we have to find the file and unzip. Do not underestimate the time it takes to find the file wherever you have download it. :-) .

    As I always install my Jvm on the root directory of my C: drive (c:\jdk15,c:\jdk16,..) . I am going to follow the same procedure again, as it will ease the procedure of adding it to my PATH route. I do not know you but I am a little tired of adding things to my PATH, that I am not going to use so I have created a .bat file which do this for me. For more details about how to getting started. Obviously, it is designed to support my best practices, but you know today is “Convention over configuration” or DIY.

    Prerequisites

    JRuby 1.1.3 or higher
    Java 5 or higher
    Rails 2.0 or higher

     Install Rails Framework ‘gems install rails -y’ (if behind a http proxy, set HTTP_PROXY=http://${http-proxy-host}:${http-proxy-port}/)
    4. Install activerecord-jdbc ‘gems install activerecord-jdbc’
    5. Install database/jdbc driver (for mysql http://mysql.com/)
    6. Generate your Ruby on Rails application (http://rubyonrails.org/)
    7. Modify database.yaml
           development:
               adapter: jdbc
               driver: com.mysql.jdbc.Driver (for mysql)
               url: jdbc:mysql://${database-hostname}/${db-schema}
               username: ${username}
               password: ${password}

    8. Modify environment.rb by adding
           require ‘active_record/connection_adapters/jdbc_adapter’

    9. Download rails-integration-${version}-SNAPSHOT.jar into the WEB-INF/lib by checking out and building the rails-integration project
    svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration
    10. Modify the template web.xml(see references below) with the right value of jruby.home
    11. Create a WEB-INF directory in the RoR application directory
    12. Copy web.xml to WEB-INF and rails-integration-${version}-SNAPSHOT.jar under WEB-INF/lib
    13. Jar up the RoR application directory contents as a WAR file

    Requests to appropriate context-root of the deployed web application should invoke your Ruby code !

    If you’d like to automate the building of a war file:
    Edit rails-integration/build.xml and add the following XML snippet
      <property environment=”env”/>
      <target name=”build-rails-war” depends=”jar”>
        <delete file=”${rails-app-dir}/${rails-app-name}.war”/>
        <mkdir dir=”${rails-app-dir}/WEB-INF/lib”/>
        <copy todir=”${rails-app-dir}/WEB-INF/lib”>
          <fileset file=”${maven.build.directory}/${maven.build.final.name}.jar”/>
          <fileset file=”${maven.repo.local}/org/jruby/jruby/0.9.1/jruby-0.9.1.jar”/>
          <fileset file=”${maven.repo.local}/asm/asm/2.2.2/asm-2.2.2.jar”/>
          <fileset file=”${maven.repo.local}/javax/activation/activation/1.1/activation-1.1.jar”/>
        </copy>
        <copy todir=”${rails-app-dir}/WEB-INF/”>
          <fileset file=”samples/scaffold/WEB-INF/web.xml”/>
        </copy>
        <replace file=”${rails-app-dir}/WEB-INF/web.xml” token=”/usr/local/jruby” value=”${env.JRUBY_HOME}”/>
        <jar jarfile=”${rails-app-dir}/${rails-app-name}.war” basedir=”${rails-app-dir}”/>
      </target>
    Make sure JRUBY_HOME is set and run
    ‘ant -Drails-app-dir=${ror-app-dir} -Drails-app-name=${war-file-name} build-rails-war’
    ${ror-app-dir}/${ror-app-name}.war should be ready for deployment !

    jruby -S gem install -y rails warbler

    $JRUBY_HOME/bin/gem install activerecord-jdbc-adapter -y

    modify database.yml

    development:
    adapter: jdbc
    driver: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost/blabla_development
    username: root
    password: root

    Modify environment.rb

    require File.join(File.dirname(__FILE__), 'boot')
    if RUBY_PLATFORM =~ /java/
    require 'rubygems'
    RAILS_CONNECTION_ADAPTERS = %w(jdbc)
    end
    I would recommend to read of The empty Way
    JRuby entries on Wordpress

    Rails::Initializer.run do |config|

    This article is based on the following references:

    Kind regards

    Categories: JRuby, sap Tags: , ,

    Desarrollo de Aplicaciones Flex con FlashDevelop – Primera Parte

    July 7th, 2009 admin No comments

    Buenas noches:

    No hace mucho que descubri el entorno de desarrollo flashdevelop.org, la verdad es aunque no he podido utilizarlo todo lo que quisiera, es bastante potente y permite desarrollar comodamente en Flex sin necesidad de utilizar el FlexBuilder o FlashBuilder. Es cierto que tiene limitaciones pero en su mayoría relativas a que el Flex SDK no posee todas las librerias existentes en el FlexBuilder.

    Instalarlo es muy sencillo y existen varios tutoriales que lo explican.  Lo que no he encontrado son tutoriales, ejemplos o artículos que lo utilicen a fondo con todas sus posibilidades. Así que he decido adentrarme yo mismo en este territorio inexplorado.

    • Antes de nada he descargarme Flex SDK. Se trata de un fichero zip que es facil de descomprimir. En mi caso, yo lo he hecho en mi disco secundario D:\FlexSDK.
    • Se ejecuta el FlashDevelop. Se selecciona la opción

    Crear un nuevo proyecto

    Debajo de la pestaña de proyectos recientes “Recent Projects”, existe la opción “New Project”. Esta opción nos dirige a una ventana emergente de donde se puede seleccionar el proyecto deseado. En este caso, se selecciona la opción “ActionScript 3 > Flex Project”.

    En este ejemplo especifico se introduce los siguientes valores:

    • Name: AddressBook
    • Location: D:\adobeflexprojects
    • Package: – Se deja en blanco -

    Automaticamente, se genera una colección de carpetas como se generarían en el caso de un proyecto utilizando FlexBuilder.

    • bin
    • lib
    • src

    En nuestro caso, se desgarga este fichero (fichero), se introduce en la carpeta lib, que se encuentra en
    D:/

    Se abre el fichero Main.mxml que se encuentra localizado en la carpeta src, al que se puede acceder desde la pestaña Project.

    1
    
    <mx:Button id="myButton" label="Hello" />

    Queda el siguiente codigo

    1
    2
    3
    4
    
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Button id="myButton" label="Hello" />
    </mx:Application>

    Una vez salvado, se pulsa sobre el botón “Test Movie”, y el SDK de Flex compila el fichero. Y si se ha cometido ningún error al copiar/pegar aparece un botón.

    A continuación, se le añade nuevos elementos de UI,como una etiqueta o un campo donde se almacena el Nombre de Pila del contacto.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    	<mx:Panel title="New AddressBook Contact" height="75%" width="75%" 
            paddingTop="10" paddingLeft="10">
    			<mx:Label id="fNameLabel" text="FirstName."/>
    			<mx:TextInput id="fName" text="Enter First Name"/>
    			<mx:Button id="myButton" label="Submit" />
    	</mx:Panel>
    </mx:Application>

    Se ha introducido elementos nuevos

    • Label
    • TextInput

    Tambien puedo introducir campos múltiples, como este campo lista que me va a permitir seleccionar el tratamiento del individuo:

    1
    2
    3
    4
    5
    6
    7
    
    <mx:List> 
    	<mx:dataProvider>
    		<mx:String>Mr.</mx:String>
    		<mx:String>Ms.</mx:String>
    		<mx:String>Miss</mx:String>
    	</mx:dataProvider>
    </mx:List>

    Esto es solo el comienzo para abrir boca,en los siguientes capitulos se comenzará de una manera más organizada entendiendo cual debe ser la organización de un desarrollo, como se organiza un formulario y como se puede dar estilos a la aplicación.

    Un saludo

    PUROMAC Madrid Event

    December 6th, 2008 admin No comments

    Buenas noches:

    Hoy he asistido al evento de Puromac en Madrid, con unos cuantos fieles, la verdad es que la cosa ha resultado de lo más divertido. Una reunión para conocerse y hablar del mundo MAC , del MacOSx y del iphone.

    Me han quedado cosas claras a resultado de esta reunión, el MAC no es un ordenador elitista pero si para la elites intelectuales, para aquellos que no les gusta conducir pero si utilizar una gran ordenador. No esta pensado ni por precio ni por características para el gran publico, sino para una pequeña gran minoria que si bien quiza no tenga un alto poder adquisitivo si tiene capacidad de distinguir productos de mayor calidad.

    Lo que me hace pensar como pueden los desarrolladores sacar partido a esta posibilidades, de momento no lo sé, alguna idea?

    Categories: Uncategorized Tags: ,

    Conferencia Rails 2008

    November 14th, 2008 admin No comments

    Un más ActivoRicordi ha estado en la conferencia Rails española. Un año más esta siendo una gran experiencia, un año más el software es la excusa para juntar gente brillante sobre un mismo techo y compartir que se esta haciendo cosas muy interesantes en este país relativos a la innovación.

    Muy lentamente se esta generando un tejido empresarial de innovación y productividad a través de la technologia “Ruby on Rails” y a su alreador. Una technologia que es la excusa para lanzar iniciativas con muchos puntos comunes

    Colaboración y comunidad: Las aplicaciones son esfuerzos colaborativos de un grupo de personas buscando situaciones win-win.

    Usabilidad : Simplicidad de uso en las interfases, flexibilidad o más bien adaptación a los usuarios.

    Productividad: Crear desarrollo productivos, competir con inversiones pequeñas con los jugadores más grandes

    Software como servicio o con servicios añadidos: El software se convierte en algo más que una licencia, es la excusa para proporcionar un servicio al usuario, flexible, agil y adaptado a sus necesidades.

    Estandarización: Enlazado con la colaboración, utilización de estandares.

    Escalabilidad: La infrastructura no debe convertirse en una limitación a las ideas y a los proyectos.

    Sin embargo, considero que este será uno de los años claves para Framework, por un lado empiezan a aparecer competidores en el mercado como Merb que ganan adeptos, y por otro la crisis obliga a muchos proyectos a darse una dosis de realidad.

    Aunque existen casos de exitos muy interesantes, me ha sorprendido mucho saber que “La Razon” corre sobre Rails, y si sigue a este ritmo “La Coctelera” pronto será conocida como “La Incubadora” : UVLog, iwannagothere.com , estos tipos no paran de crear propuestas nuevas.

    Cierro aquí para asistir a la Keynote de “Obie Fernandez”.

    Hasta el proximo año!!

    Ruby on Windows Articles

    October 12th, 2008 admin 1 comment

    Hi All:

    Not very recently ago, I found this great site about how to automate our main and basic tasks on Windows using Ruby called Ruby on Windows

    . Being a lifetime ruby beginner, I found that maybe I could use this for my windows daily task and meanwhile learn a little bit more of Ruby.

    Apart from the Winsows Office articles (main objective of the research), I specially like the articles about wxruby as sometimes I feel in the need or creating my own GUI for some of the tasks I and doing. Since I have no interest in program with Visual Basic .Net, as I feel a huge industrial development environment is not suit for my specific need, I feel wxruby is suitable tool for me.

    Kind regards

    Categories: Ruby Tags:

    QRCodes: First glimpse

    September 13th, 2008 admin No comments

    I discovered QRCodes at 11870.com where they are using them on a Marketing Campaign. There is nice article in Spanish which explains what they are.Also there is another post from a spanish blog which relates first introduction of an occidental guys to it.

    For your benefit, I include its automatic translations to English

    For our non-Spanish readers I will do a summary:

    From 2000 at Japan all magazines and products have started to use QRCode, a version of the two-dimensional code bar for Kanji characters, which is readable with the use of a mobile camera: Simply making a photo is enough for saving the information inside of the mobile device.Companies like McDonalds use them to inform about ingredients or nutritional facts, or MoviStar offering discounts. At Barcelona, they are using them for providing tourist information on the sightseeing points to Japanese tourists.
    It is a technology designed for the warehourse but it is mainly target now a mass-consumer products.

    How to read a QRCode?

    Reading software is available for many mobile manufacturers such as Nokia or from companies specialized in this technologies such as i-Nigma or Kaywa. Nokia provide a page which explain which readers are compatible with each of its phones and which phones have Nokia barcode reader already preinstalled on your device.
    This page provide very good information about the applications which support the most common phones.

    For iphone users, there is a open source project which provide a reader application called QRDecode, obviously it is only available for hijacked phones on version 1.x, and for 2.x users. Unfortunately, I am not aware. Please, comments welcome. There is a page which explains how to install it with the installer.

    There is also another application called 2D Sense Platform which seems a commercial application which support not only QRCodes but also traditional DataMatrix codes.


    How to produce a QRCode?

    Nokia has a page where you can produce through a web application which can help to play around a little bit in order to understand all the possibilities.

    The first thing we notice is that Nokia recommends us not to exceed 60 characters of text, as mobile code starts getting too complex for camera phones to handle.
    Kaywa has also its own application to create this QRCodes from URL, Texts, Phone Number and SMS.

    Well, folks that is enough for today. Next chapter we will see how to create programmatically QRCode from XML through J2EE or Ruby on Rails.

    Tutorials in Routing in Rails 2.0

    August 29th, 2008 admin No comments

    Developing Java with SAP MaxDB Database – Part 1

    August 27th, 2008 admin No comments

    SAP MaxDB is a relational database that provides functions for creating, using, and managing databases and the software comprises the database kernel, tools, and interfaces.

    SAP MaxDB has its own JDBC Driver which we can used to execute SQL statements with Java. It is a JDBC 2.0, that you can find on the following location of the installed MaxDB JDBC driver file at:
    \runtime\jar\sapdbc.jar . For instance, when I installed on my local machine I did it on the following location:
    D:\sapdb\programs\runtime\jar
    The java class for the JDBC drive is the com.sap.dbtech.jdbc.DriverSapDB

    Well, that enough for today. On the next
    Kind regards