Ajax Scaffold Generator for Rails Released


#1

I just released a whole new version of the Ajax Scaffold Generator (for
Ruby
on Rails). The generator creates a scaffold page like the typical rails
one,
except adding, editing and deleting are all done inline. The generated
scaffold is valid XHTML strict and fully styled right out of the box.

Check out the demo:

http://ajaxscaffold.height1percent.com/
And the how-to:

http://www.height1percent.com/articles/2006/02/21/on-the-new-ajax-scaffold-generator

Its a generates a much better starting point for an Ajax’ified
application
or for any application than the existing scaffold generator. I hope you
guys
find it useful.
Thanks.


Richard W.
Interface Designer
Blog | www.height1percent.com
Easy to use online calendar | www.kiko.com
Keep in touch with relatives | www.youlookfamiliar.com


#2

On Sat, 2006-02-25 at 16:36 -0500, Richard W. wrote:

And the how-to:

http://www.height1percent.com/articles/2006/02/21/on-the-new-ajax-scaffold-generator

Its a generates a much better starting point for an Ajax’ified
application or for any application than the existing scaffold
generator. I hope you guys find it useful.


looks impressive and I suspect that I will be playing with it soon. Nice
demo and description too.

Thanks

Craig


#3

On 2/25/06, Craig W. removed_email_address@domain.invalid wrote:

demo and description too.
It does look good. Good enough that I posted a message about it at
the Apress blog – http://ablog.apress.com/?p=938

I can’t wait to see how this fits in with a small app I’m doing at work.

Thanks

Craig


Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails


thanks,
-pate


#4

kool… but paging support would be excellent!


#5

I downloaded this last night, and regenerated scaffolds for about half a
dozen models on one of my projects. It is simply amazing. I had no
hiccups, and it looks and works perfectly on every browser I threw at
it. thanks for your hard work on this Richard. (and unlike my earlier
email to Zed, I made sure to get your name right).

Brian


#6

Very cool!

-Ezra


#7

Jim C. wrote:

It worked fine with Safari, and Firefox.

But, despite that - very nice :slight_smile:

-jim

I got that same error also when trying the demo running Safari under
Tiger (intel). However, I think it’s something with the demo? It was
random for me and seemed to only happen after a canceled Edit of a row.
After reloading the data I was able to edit again.

-Sean


#8

On Feb 25, 2006, at 1:36 PM, Richard W. wrote:

http://www.height1percent.com/articles/2006/02/21/on-the-new-ajax-
scaffold-generator
Its a generates a much better starting point for an Ajax’ified
application or for any application than the existing scaffold
generator. I hope you guys find it useful.
Ya know, I just spent the past two days teaching myself RoR from
scratch. I’d gotten about 3/4 of the functionality you have (with
none of the style) and this comes out. Thanks a ton! Now I can get
back to doing the application work, and stop dorking around with the
interface so much!

RoR just went from RAD to k-RAD. Thanks a ton!


#9

David Olbersen wrote:

On Feb 25, 2006, at 1:36 PM, Richard W. wrote:

http://www.height1percent.com/articles/2006/02/21/on-the-new-ajax-
scaffold-generator
Its a generates a much better starting point for an Ajax’ified
application or for any application than the existing scaffold
generator. I hope you guys find it useful.
Ya know, I just spent the past two days teaching myself RoR from
scratch. I’d gotten about 3/4 of the functionality you have (with
none of the style) and this comes out. Thanks a ton! Now I can get
back to doing the application work, and stop dorking around with the
interface so much!

RoR just went from RAD to k-RAD. Thanks a ton!

Thanks for the kind words everyone. If you found the scaffold at all
useful or interesting please drop by the lastest post on my blog and
opon on what you’d like to see built/fixed next. Thanks again.

http://www.height1percent.com/articles/2006/02/26/on-the-ajax-scaffold-feedback

Rich


#10

Leon L. wrote:

kool… but paging support would be excellent!
To get pagination, I added these lines to view_list.rhtml, right after
the table.

<%%= link_to '< @pages.current.previous } if @pages.current.previous %> <%%=pagination_links_each(@pages, :window_size => 4) do |n| "#{n}"; end %> <%%= link_to '>>', { :page => @pages.current.next } if @pages.current.next %>

AND replaced the first 20 lines in controller.rb

class <%= controller_class_name %>Controller < ApplicationController

<% unless suffix -%>
def index
list
render_action ‘list’
end
<% end -%>

<% for action in unscaffolded_actions -%>
def <%= action %><%= suffix %>
end
<% end -%>

def list<%= suffix %>
#@<%= plural_name %> = <%= model_name %>.find :all
#render :layout => false
@pages, @<%= plural_name %> = paginate :<%= plural_name %> , :per_page
=> 10
end


#11

kevin wrote:

Leon L. wrote:

kool… but paging support would be excellent!
To get pagination, I added these lines to view_list.rhtml, right after
the table.

<%%= link_to '< @pages.current.previous } if @pages.current.previous %> <%%=pagination_links_each(@pages, :window_size => 4) do |n| "#{n}"; end %> <%%= link_to '>>', { :page => @pages.current.next } if @pages.current.next %>

AND replaced the first 20 lines in controller.rb

class <%= controller_class_name %>Controller < ApplicationController

<% unless suffix -%>
def index
list
render_action ‘list’
end
<% end -%>

<% for action in unscaffolded_actions -%>
def <%= action %><%= suffix %>
end
<% end -%>

def list<%= suffix %>
#@<%= plural_name %> = <%= model_name %>.find :all
#render :layout => false
@pages, @<%= plural_name %> = paginate :<%= plural_name %> , :per_page
=> 10
end

Yep, you could do that if you really need pagination at this point. A
better solution would involve one where pagination would work more
client side. For example if you deleted 3 rows on the table it should
pull up 3 from the next page instead of just having a shrinking page and
inconsistent data when you go to the next.

We’ll support that eventually, and sooner than later.

Rich


#12

This is superb. Thank you so much for your contribution!!

One point though - I may be missing something obvious but when I create
the
following scaffold using a module:

ruby script/generate scaffold ajax_scaffold Tariff ‘admin/tariffs’

When clicking to ‘Create New’ it has a routing error stating it can’t
find:
admin/admin/tariff/new

I go into the code and find all the links and controllers are relative
“admin/tariff” I can solve the issue by one of two ways:

  1. Add a forward slash before admin “/admin/tariff”
  2. remove the “admin/” so the relative path is correct.

Not a worry as I have it working but just thoguht I’d let you know.

All the best - Keep up the good work!!

Doug


#13

On Sun, Feb 26, 2006 at 01:58:49AM +0100, Brian wrote:

hiccups, and it looks and works perfectly on every browser I threw at
it.

Well, I threw Opera 9 p2 (3216) under OSX at it, and when creating a
customer record received a JavaScript popup box “TableRow: both
parameters must be a

tag.”

It worked fine with Safari, and Firefox.

But, despite that - very nice :slight_smile:

-jim


#14

On 2/28/06, Conrad T. removed_email_address@domain.invalid wrote:

Hi, coudl someone tell me what to down load and how to install it?

It’s right there on the page:

Look for “Getting Started”

http://www.height1percent.com/articles/2006/02/21/on-the-new-ajax-scaffold-generator


Greg D.
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/


#15

Hi, coudl someone tell me what to down load and how to install it?

Thanks in advance,

-Conrad


#16

Hi, when I go to the download area, I’m presented with three files for
the 2.1.0 release. Two of the files are compressed archives and one of
them is a .gem file. It’s simply not clear as to what to download and
it seem that some steps were skipped to me.

-Conrad


#17

Conrad T. wrote:

Hi, when I go to the download area, I’m presented with three files for
the 2.1.0 release. Two of the files are compressed archives and one of
them is a .gem file. It’s simply not clear as to what to download and
it seem that some steps were skipped to me.

-Conrad

The easiset thing to do is to first install gem, which effectively is
Ruby’s package manager. Get gem from rubyforge :

http://rubyforge.org/frs/?group_id=126&release_id=2471

and unpack it into a working directory.

From the package directions:

If you don’t have any gems install, there is still the pre-gem
approach to getting software … doing it manually:

  1. DOWNLOAD FROM: http://rubyforge.org/frs/?group_id=126
  2. UNPACK INTO A DIRECTORY AND CD THERE
  3. INSTALL WITH: ruby setup.rb all (you may need admin/root privilege)

Now you can do things like:

gem install ajax_scaffold_generator --remote

and everything needed for ajax_scaffold_generator will be identified and
downloaded for you (after you consent).

Installing gem now will make extending and maintaining ruby and rails
much easier for you later.

Regards,
Jim


#18

On Tue, Feb 28, 2006 at 09:18:44PM +0100, James B. wrote:
[…]

gem install ajax_scaffold_generator --remote

and everything needed for ajax_scaffold_generator will be identified and
downloaded for you (after you consent).

Installing gem now will make extending and maintaining ruby and rails
much easier for you later.

It occurs to me after using a bunch of these - why are the rails gems
not labeled as such?

There are lots of gems, and many of them are generic ruby
packages. Perhaps we could encourage people who make gems for rails to
specify that they’re rails-specific in the names.

It would be much clearer if this was rails_ajax_scaffold_generator.


- Adam

** Expert Technical Project and Business Management
**** System Performance Analysis and Architecture
****** [ http://www.everylastounce.com ]

[ http://www.aquick.org/blog ] … Blog
[ http://www.adamfields.com/resume.html ]… Experience
[ http://www.flickr.com/photos/fields ] … Photos
[ http://www.aquicki.com/wiki ]…Wiki
[ http://del.icio.us/fields ] … Links


#19

On 2/26/06, Richard W. removed_email_address@domain.invalid wrote:

scratch. I’d gotten about 3/4 of the functionality you have (with
http://www.height1percent.com/articles/2006/02/26/on-the-ajax-scaffold-feedback

How could I modify this to do file uploads? I can’t do uploads inside
form_remote_tag, right?


#20

Doug: Thanks for pointing that out. Honestly, I hadn’t done much with
the original scaffold generator outside of having a different controller
name than the model name. I will add this into my test scenarios and
hopefully release a minor point release to cover this issue. Thanks
again for bringing it to my attention.

Doug B. wrote:

This is superb. Thank you so much for your contribution!!

One point though - I may be missing something obvious but when I create
the
following scaffold using a module:

ruby script/generate scaffold ajax_scaffold Tariff ‘admin/tariffs’

When clicking to ‘Create New’ it has a routing error stating it can’t
find:
admin/admin/tariff/new

I go into the code and find all the links and controllers are relative
“admin/tariff” I can solve the issue by one of two ways:

  1. Add a forward slash before admin “/admin/tariff”
  2. remove the “admin/” so the relative path is correct.

Not a worry as I have it working but just thoguht I’d let you know.

All the best - Keep up the good work!!

Doug