News

Rails Web Toolkit: My first rwt application in rails 3

Added by Sergio Brant about 1 year ago

I was wondering if rwt would work with rails 3. For my surprise, it worked. Here are the steps I followed:

  • Create a new rails 3 application:
    $ rails -v
    Rails 3.0.1
    $ rails new rwt_in_rails3
          create  
          create  README
          create  Rakefile
          create  config.ru
          create  .gitignore
          create  Gemfile
          create  app
          create  app/views/layouts/application.html.erb
    ...
          create  tmp/pids
          create  vendor/plugins
          create  vendor/plugins/.gitkeep
    
    
  • Install the rwt plugin and the ExtJs javascript library
    $ cd rwt_in_rails3/public
    $ wget http://www.extjs.com/deploy/ext-3.3.0.zip
    $ unzip ext-3.3.0.zip
    $ mv ext-3.3.0 ext
    $ rm ext-3.3.0.zip
    
    $ cd ../vendor/plugins
    $ git clone git://github.com/smbrant/rwt.git
    
  • Create a new controller with two actions
    $ cd ../..
    $ rails g controller desktop index test
    
  • Remove the application.html.erb file
    $ mv app/views/layouts/application.html.erb app/views/desktop/index.html.erb
    
  • and edit app/views/desktop/index.html.erb like this:
    <!DOCTYPE html>
    <html>
      <head>
        <title>Testing Rwt in Rails3</title>
        <link rel="stylesheet" type="text/css" href="/ext/resources/css/ext-all.css" />
        <script type="text/javascript" src="/ext/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="/ext/ext-all.js"></script>
        <script src="/desktop/index.rwt" type="text/javascript"></script>
        <%= csrf_meta_tag %>
      </head>
      <body scroll='no'>
      </body>
    </html>
    
  • Edit app/controllers/desktop_controller.rb like this:
    class DesktopController < ApplicationController
      def index
        respond_to do |format|
          format.html
          format.rwt {rwt_render}
        end
      end
    
      def test
        respond_to do |format|
          format.html
          format.rwt {rwt_render}
        end
      end
    end
    
  • Now let's create our main rwt view, file app/views/desktop/index.rb:
    rwt_app do
      toolbar do
        menu('Tests') do
          menu_item('First test',function("alert('hello!')"))
          menu_item('Second test',call_view('/desktop/test.rwt'))
        end
      end
    end
    
  • And a test window, defined in the rwt view app/views/desktop/test.rb:
    window('My first window in rails3',200,200) do
      button('Show something') do |b|
        b.on('click') do
          message('Hello world')
        end
      end
    end
    
  • It's finished! Let's run it:
    rails start
    
  • Go to http://localhost:3000/desktop/index:

Rails-MG: Encontro do dia 26/01/2009

Added by Sergio Brant about 2 years ago

Rails Web Toolkit: Enabling :xtype in component even if not in lazy rendering

Added by Sergio Brant about 2 years ago

In ExtJs the config parameter xtype have no effect when used in a constructor call (new Ext.Component({xtype=...})). In Rwt you can use it in any case (after commit commit:8d7c3933). This is nice when you are trying new configuration options.

So, for example, you can now create a window using a syntax like this (more ext like)

component(:xtype=>'window',:title=>'Test Window',:width=>200,:height=>200) do |w|
  component(:xtype=>'button',:text=>'Close me!') do |b|
    b.on('click') do
      w.close
    end
  end
end.show

Or, in the rwt way:
window('Test Window',200,200) do |w|
  button('Close me!') do |b|
    b.on('click') do
      w.close
    end
  end
end

Rails Web Toolkit: Restfull_scaffold and master branches merged

Added by Sergio Brant about 2 years ago

Rwt and Rwt_home updated. You can now use the generator rwt_scaffold to create a [[scaffold]] using rwt.

Rails-MG: Encontro do dia 15/12/2009

Added by Sergio Brant about 2 years ago

Muito bom o encontro, contando com um número maior de participantes. Tivemos a presença honrosa da primeira participante do sexo feminino!

Rails Web Toolkit: Ext Scheduler Component

Added by Sergio Brant about 2 years ago

Mankz developed the Ext Scheduler Component. It could be very usefull for those dealing with time scheduling systems.

Rails Web Toolkit: Using the latest (edge) version of RWT_HOME

Added by Sergio Brant about 2 years ago

The development branch of RWT_HOME (demo rwt application) can be downloaded and installed following these steps:

  • Clone the rwt_application
    $ git clone git://github.com/smbrant/rwt_home.git
  • Checkout the edge branch (restfull_scaffold)
    $ cd rwt_home
    $ git checkout origin/restfull_scaffold -b restfull_scaffold
    $ mkdir tmp
    $ mkdir log
    $ mkdir vendor/plugins -p
  • Clone and checkout rwt
    $ cd vendor/plugins
    $ git clone git://github.com/smbrant/rwt.git
    $ cd rwt
    $ git checkout origin/restfull_scaffold -b restfull_scaffold
  • Download and unzip ExtJs in public
    $ cd ../../../public
    $ wget http://www.extjs.com/products/extjs/download.php?dl=extjs310
    $ unzip ext-3.1.0.zip
    $ mv ext-3.1.0 ext
    $ rm ext-3.1.0.zip
  • Start the application
    $ cd ..
    $ ruby script/server
  • Access at http://localhost:3000

Rails-MG: Encontro do dia 05/12/2009

Added by Sergio Brant about 2 years ago

Participantes:
  • @harlley, @daltojr, @danielvlopes, @sobrinho, @smbrant, @joaovitor, @massa0000 e outros
Assuntos:
  • Apresentação geral dos participantes
  • Comentários / brainstorm / happy hour
  • Propostas para novos encontros
  • Procura por locais mais adequados
  • Propostas para futuras palestras
  • Próximo encontro em 15/12/2009 com palestra do @sobrinho

Rails Web Toolkit: New RWT demo site

Added by Sergio Brant about 2 years ago

A new demo site is available showing examples and comparing the use of javascript code to drive extjs with ruby code (using rwt) to achieve the same results. You will see that the ruby code is much clean and enables easy interface with the rails controllers.

But in the same way that rwt makes it easy to write extjs views using ruby, the advanced extjs user shouldn't be constrained in using the more sofisticated javascript api. So rwt enables the use of javascript views with a path to variables in rails controllers via injected erb code.

Inside the examples menu you can activate the 'code view' to see the details of how the application was implemented.

Rails Web Toolkit: Using the latest version of RWT

Added by Sergio Brant about 2 years ago

  • Create a test application to test the plugin
    $ rails mytest
  • Clone rwt and checkout the development branch
    $ cd mytest/vendor/plugins
    $ git clone git://github.com/smbrant/rwt.git
    $ cd rwt
    $ git checkout origin/restfull_scaffold -b restfull_scaffold

Also available in: Atom