Sean Chittenden – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




Sean Chittenden talks about his Rails re-design work with Penny-Arcade.com, server scalability, and the open source business model.

Sean Chittenden – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




Sean Chittenden talks about his Rails re-design work with Penny-Arcade.com, server scalability, and the open source business model.

inline RJS


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




In my previous article I was playing with RJS templates and finding easy way to generate them. Well Thomas just posted some new goodies see http://mir.aculo.us/articles/2006/01/21/new-inline-rjs-for-rails. For quick updates no need to have a separte .rjs file.

class UserController < ApplicationController
def refresh
render :update do |page|
page.replace_html(‘user_list’,
:partial => ‘user’, :collection => @users)
page.visual_effect :highlight, ‘user_list’
end
end
end

.rjs and link_to_function


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




A neat little trick is that .rjs templates can be used to generate local javascript functions and be invoked without doing a server roundtrip.

playground_controller.rb

class PlaygroundController < ApplicationController
def rjs
response.headers[‘content-type’] = ‘text/html’
end
end

rjs.rhtml



<%= javascript_include_tag :defaults %>

Javascript function test

<%= link_to_function(‘Add’, ‘add_item()’ ) -%> |
<%= link_to_function(‘Clear’, ‘clear_list()’) >






    The rjs method in the PlaygroundController set’s the content-type as we perform a render of an rjs from within a .rhtml and this seems to change the content-type, so we need to reset it.

    _function.rjs

    page << ‘function add_item() {’
    page.insert_html :bottom, ‘list’, content_tag(‘li’, ‘item’, :id => ‘list_item’ )
    page.visual_effect :highlight, ‘list’, :duration => 3
    page << ‘}’

    page << ‘function clear_list() {’
    page.replace_html :list, ""
    page.visual_effect :highlight, ‘list’, :duration => 3
    page << ‘}’

    In the partial function.rjs we insert the function declaration before writing to the page object. This allows us to invoke the additem _ and clear_list _ methods using the link_to_function _ from in the .rhtml file. Note also in the .rhtml file we invoke directly the update_page method to insert three calls to add_item().

    The generated html files looks like this






    Javascript function test

    Add |
    Clear

Scott Raymond – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




Scott Raymond, developer of Blinksale, Icon Buffet, and other wonderful Rails apps.

Scott Raymond – Ruby on Rails Podcast


This post is by Ruby on Rails Podcast from Ruby on Rails Podcast


Click here to view on the original site: Original Post




Scott Raymond, developer of Blinksale, Icon Buffet, and other wonderful Rails apps.

Xml Builder


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




I created the new Playground category on this blog to expose various aspects regarding Ruby On Rails that I am exploring. It may raise more questions than provide answers, but in any case don’t hesitate to jump in and add your 2 cents.

The xml_builder method here after uses the render_to_string method to create some xml structure. The xmlstring could as well have been in a separate .rxml file and and a simple render statement instead of render_as_string could have saved one line of code. But hey, that’s what the playground is for!

class PlaygroundController < ApplicationController
def xml_builder
xml_string = <<-XML_END
xml.test do
xml.language(name)
xml.description(“Rocks!”)
end
XML_END
result = render_to_string(:inline => xml_string, :locals => { :name => ’Ruby’}, :type => :rxml)
render_text result
end

end

The output:


Ruby
Rocks!

Flex vs. ROR


This post is by Daniel Wanja from onrails.org


Click here to view on the original site: Original Post




Ed just asked me: "Why, ultimately would you say ROR is better than Flex? There’s a great debate at the moment.

My swiss style answer: "This is a very interresting question. I effectively use
both technologies with different customers on different projects. And
I like both, they have different strength. Flex 1.5 answers only the
UI question and doesn’t help with the persistence side of a project.
Flex 2.0 will provides some answers to the persistence integration
with their Enterprise Services. Flex is really awesome to build a
custom UI. Rails on the other hand provides lots of power if you have
control on the database schema and is a full “web” stack. It provides
a nice framework to build the views and provides some pretty powerfull
ways to create dynamic html pages. Rails can we very productive. So in
other words, I don’t prefer one over the other. It really depends on
the specifics of the problem to be solved, the technical expertise of
a customer and the future direction a customer wants to go to define
if one technology is more appropriate than another."