AjaxScaffold has been deprecated in favor of ActiveScaffold
So I just gemmed and uploaded the v2.0 release of the ajax scaffold generator. There are quite a few improvements in this version, most notably:
- The generated scaffold code looks production ready: valid XHTML, CSS, fully styled.
- It now uses a <table>
- Its designed to be used as a component so you can easily create an admin console with a couple generated scaffolds.
- A number of CSS styles have already been included for commonly used elements like required field labels, example field input and for some basic form layout control (explained later in this article).
- Works on Firefox 1+, IE 6+ and Safari 2+ (It may work on others, but I haven’t tested anywhere else, so let me know what you find out)
Why not jump over to the demo page and check it out and then come back here for the walkthrough. (and it wouldn’t hurt if you went and Dugg this article somewhere in between
).
Some of this information is outdated as of version 3.0.0, check out the 3.0.0 release notes
Getting Started
Getting up and running is fairly straightforward, but I’ll hold your hand just in case
- Install the Ajax Scaffold Generator gem
gem install ajax_scaffold_generator
ruby script/generate ajax_scaffold Widget
or on *nix
script/generate ajax_scaffold Widget

Thats it! You have a fully working ajaxified scaffold page.
Adding form validation
Of course we probably want to add some validation to our objects so lets start by making widget.name required.
We add the following to models/widget.rb
class Widget <strong>validates_presence_of :name</strong> end
And now for some UI sugar we will add a class and an asterisk to the name label in views/widget/_form.rhtml:
<div class="form-element"> <label <strong>class="required"</strong> for="widget_name">Name<strong>*</strong></label> <%= text_field 'widget', 'name' > </div>
And now when we attempt to create a widget without a name we get this helpful message.

UI Sugar
I also find it good practice to give people examples of what their form input should look like (help text is good too but I prefer examples). So lets put an example on the version field:
<div class="form-element"> <label for="widget_version">Version</label> <%= text_field 'widget', 'version' %> <strong> <label class="example">ex: v1.0, v0.2.4, rc4</label></strong> </div>
Obviously putting the example under the input is just personal preference and when I have client-side errors I will usually put the example on top, but thats neither here nor there.
Next I may want to make sure that a certain set of fields always appear on a new line. A good example of this might be a situation where I want First Name and Last Name on one line and Address to always be on a line beneath those two elements. To accomplish this we simply wrap each “section” of form elements in a <div class=”row”> in our views/widgets/_form.rhtml:
<fieldset>
<strong><div class="row"></strong>
<div class="form-element">
<label class="required" for="widget_name">Name*</label>
<%= text_field 'widget', 'name' %>
</div>
</div>
<strong><div class="row"></strong>
<div class="form-element">
<label for="widget_version">Version</label>
<%= text_field 'widget', 'version' %>
<label class="example">ex: v1.0, v0.2.4, rc4</label>
</div>
</div>
</fieldset>
And voila!

General Error Messages
This information is outdated as of version 3.0.0, check out the 3.0.0 release notes
Handling when something goes very wrong is an oft overlooked part of many systems. Your generated scaffold has a fairly simple way of passing general errors back to the user. For the same of example I am going to short circuit the controller method for creating a new widget to always return one of these general errors:
def new ... #render :layout => false <strong>render :inline => "Muwhahah! No new widget for you!", :layout => false, :status => 500</strong> end
Now watch what happens when I try to create a new widget:

Ouch denied!
Embedding multiple scaffolds on the same page
One of the beauties of AjaxScaffolds is that they are designed to be used as components that you can embed on other pages. I’ve documented this in a later article here.
A Few Caveats
There are just a few caveats to all of this. These should hopefully be resolved in future versions (which anyone is more than welcome to pitch in on).
The scaffold only generates properly when both element names are the same, thus the following doesn’t work (without some tweaks to the code generated<strike>ruby script/generate ajax_scaffold Widget WidgetConsole</strike>
There is no graceful degredation for clients without JS
Added in 2.2.0There is no pagination or find feature (thanks to Craig for reminding me to point this out)
Added in 3.0.0
Future Direction & Wrapping Up
Well that’s is about all we have for the first release of Ajax Scaffold Generator v2.
Just to give you an idea of where we are going here are some future improvements in the development queue:
- Make the tables sortable
- Export table data to CSV
- Ability to specify different types of messages sent to the client (info, warning, etc) without having the operation fail (ie not having to set status = 500)
- Have it update regularly to pick up on changes made by other users
- Client side validation
- Use JSTs to create the forms (update, create) to save server requests
- Print stylesheet
- Fix those caveats I listed previously
Undoubtedly, as with any first release, there will be some bugs to please forward those and any feedback you might have either via the comments on this blog or by email me at rrwhite AT gmail.com.
And finally, I need to give a shout out to Mark James for his Silk icons and stay tuned to this blog as I’ll be writing up more of the interesting implementation details and technical workarounds that I had to do to make this all work (If your into that sort of thing).
Happy generating.
103 Comments
Hi,
It’s a great tool you’ve created. However, after I set it up, when I click on “Create”, the box does not display as it did in the demo page. I followed all the procedures provided above. The database i used is MYSQL. but i dont think that’s the reason that caused it. Please let me know what you think.
P.S i tried on both firefox 1.5 and I.E 6
Thank you
nevermind, it was a caching problem. shift+reload fixed it. Thank you!
Man, if that workaround for doing IE-safe insertions on tables is your creation, it *really* deserves to be part of Prototype proper. I’d love to see that as a patch!
Great work.
Thanks for the kind words Scott. And yes, that code is actually my own work. I plan to document it in a later blog post and probably should submit it to prototype, I’ll look into that.
As Rich outlined above, one of the few caveats to his scaffolding is that it only generates properly when both element names are the same, as in: ’script/generate ajax_scaffold Page Page’ rather than ’script/generate ajax_scaffold Page Admin’. However this can be sorted b y changing two things:
1) Edit the index.rhtml (which in this example will be in the admin view). It calls on a controller of ‘page’ which doesn’t exist. Change this to call on a controller of ‘admin’.
2) Rename the partial, which in this case will be called ‘_admin.rhtml’ to ‘_page.rhtml’.
Than everything should work fine!
Great thanks to Rich for the hard work he’s put into it, it’s pretty amazing.
Hi,
I managed to implement your code and it works perfectly but is it possible to use the ‘render partial’ call in another page? The edit and delete seems to work but the create dosn’t.
Thanks
Steven: I’m not sure what you mean, what are you trying to render on another page? You can obviously include the whole scaffold in another page using the render_component, but are you trying to render just one of the forms by themselves?
I’ve posted a ton of sorting and filtering code for your rails scaffolds. It wouldn’t be too hard to convert this to ajax to re-fill the table at will; feel free to adapt at will. Great article!
http://blog.caboo.se/articles/2006/02/02/more-cracked-out-scaffolding-element-twisty
Thanks Richard, I’m trying to render the entire thing on another page using the render_component but the create button dosnt seem to work but the edit and delete does. I get no errors.
I’ve been having a problem with the demo page. There seems to be some sort of bug.
I’m using Safari on 10.4.
Everytime I click “Edit” on the last item in the table it crashes the broswer. The other items work fine.
PatrickH: Thats very interesting, I will add that scenario to my testing for the next point release.
Steven: Do you see the /controller/new request in your server logs? That’s where I would start. If you would like we can talk this conversation offline and you could email me some more information.
First, nice work.
I implemented this in a small project that I have that is using CSS to create a typical side bar nav with a main content area. I noticed a problem with the CSS in the scenario that I believe can be easily solved, but I am not sure that my change is without consequences. By changing:
.list-header {
position: relative;
background: #005CB8;
clear: both;
}
to:
.list-header {
position: relative;
background: #005CB8;
}
This small change allows things to work just fine inside of the overall CSS layout structure (the problem is that another float left column forces the entire list of entries down the page).
So, my question is….for what reason did you include the clear:both. Everything appears to work without it?
Thanks and keep up the great work.
Mike: I actually have no idea why thats in there. Obviously some vestigal (sp?) style in the CSS. Luckily I read your post right before posting 2.1.0 so that patch made it in there. Thanks.
I would be interested in seeing what happens when the list is long…does it paginate. Does it have a ‘find’ function or only the basic CRUD stuff?
Craig: It currently does NOT paginate or have a find function. Those two things should definently be on that TODO list at the end of the article. A simple pagination wouldn’t be too hard, the main reason it doesn’t have it currently is that a) I created this originally for my own projects where the lists should never be too long and b) it would take more time
Great job, Richard! One feature request. I tried this with a table including a date field, and the resulting form controls included dropdowns with limited date-ranges (year from 2001-2011 if memory serves). Could work fine for lots of folks, but not very useful in my case, since the field in question holds birthdates, all of which are outside the default range displayed.
I can edit that, of course, but the resulting dropdown will have to be very big — and it seems like it would be more ‘generic’ for the scaffold not to make these kinds of assumptions. Would it be possible to default to editable (AJAXified) controls for date fields, so users could override the default options if needed? Or am I missing some more obvious way of dealing with the situation?
CJ: You hit the nail on the head with “it would be more ‘generic’ for the scaffold not to make these kinds of assumptions.” One of the main premises here is not to be all things to all people if you will. But to be one thing for all people to start from. Having you change that field to handle birthdates is far easier and simpler for both you and I than creating some complex way of telling the scaffold what type of fields you want ahead of time.
You are pretty much expected to change the form (especially if you have to input dates using the Rails default date input *yuck*) after generation if you want something special done. The good news is that changing the form for the Ajax Scaffold is no different than changing it for the regular scaffold generated form. The Ajax stuff is all handled externally to that form so you muck with the inputs as much as you want.
As an aside, I haven’t mentioned this before but I plan to release something akin to the Datebox Rails Engine (maybe just a lightweight version of that) that will become the default date input for all scaffold generated code.
Another way of doing cross browser table manipulation with Prototype:
http://www.larrygoats.com/articles/2006/01/26/taconite-prototype-rails
Nice, but why oh why generate code like:
<a href=”#” onclick=”new Ajax.Request(‘/CustomerConsole/edit/1930′, {asynchronous:true, evalScripts:true, onComplete:function(request){AjaxScaffold.editOnComplete(request,’customer’, 1930);}, onFailure:function(request){AjaxScaffold.editOnFailure(request,’customer’, 1930);}, onLoading:function(request){AjaxScaffold.editOnLoading(request,’customer’, 1930);}, onSuccess:function(request){AjaxScaffold.editOnSuccess(request,’customer’, 1930);}}); return false;” rel=”nofollow” rel=”nofollow”>Edit</a>
When you could keep the lot in an own function and just parse the ID?
Chris: Yes, that code is a bit bloated but I’m still not quite sure what your proposal is for how it should change. Please explain more.
Larry: I’d have to use it to be sure, but that looks like exactly where I was going with my TableRow.MoveBefore and TableRow.MoveAfter. Actually I was just going to extend Insertion.Before and Insertion.After to actually work for table elements, does your work already solve this or do I still have to do it in two steps (insert, move).
Larry: Looking at the code for taconite_for_prototype.js I see that it relies on node.insertBefore which won’t work on tables in ie6 (see http://msdn.microsoft.com/workshop/author/tables/buildtables.asp). This is why I plan create my own patch of prototype Insertion in the next release of the AjaxScaffold.
File uploads would be cool…
Richard, I have not had any problems moving around table rows or replacing table rows using the taconite_for_prototype extension with ie6. I would love to know under what circumstances insertBefore fails.
To address your first question, I use the Insertion class when I want to place a new row in a specific location in the table. I use the Relocation class when I want to move an existing row to a new location in the table.
This evening, I’ll do some more tests with ie6 and see if I can find any points of failure. I did some googling and didn’t find any reference to tables in ie6 not supporting insertBefore.
I get an error message in my java console “Ajax is not defined” and there is no formatting on the page. Are there some dependencies I need to download? (css and js files)
Larry: Ahhh, I was almost sure that it didn’t work, but if it does thats awesome. That saves me the work creating the exact same thing
. I’ll definently use that in the next version of the generator if you don’t mind.
Joe: file uploads? I don’t follow.
David: Java console eh? I suppose I never mentioned it on this howto, but this is a tool for Ruby on Rails. Does that solve your problem?
sorry i meant the browsers javascript console…
I’m new to Ruby on Rails and your ajax scaffold is beautiful! I want to get it… it seems to install perfectly, but when I load a page I get the table with no style or javascript (ajax). Any suggestions?
Thanks,
David
ah! figured it out… (and feeling sheepish).
David: haha, fess up what was it?
Richard, by all means use and abuse the extension. Let me know If you find any bugs or have any suggestions for improvements.
I was looking at the subdirectory (e.g. widgets/list vs widgets/).
Pretty bright, huh? After checking ‘everything but’ it occured to me check to see if I had the correct url….
BTW – this is great stuff. I’m loving it: now I just need to figure out how to customize lists and forms to suit my needs.
I’m wondering if it makes sense to generate an xxxx.rhtml in layouts because the scaffold simply falls outside of the rest of the site when you do that. Wouldn’t it be better to simply include in the instructions “include this stylesheet and these javascript files in your application.rhtml”?
Gregory: You may be onto something, at the least documenting what needs to be done could be a decent idea. But, I think it makes sense in that it follows the convention of what the standard scaffold generator creates. Going back to the whole Rails philosophy of show don’t tell I would think it would be better just to show them a working scaffold and what is required and letting them figure out how to mux it in from there. The idea is that you are generally starting from scratch, if you aren’t then presumably you would know to delete the generated layout and how to port its header information over.
Another thing that I would like to see documented is how I can change the template the scaffolding system is using to generate the table. I would like to add some behaviors to mouseovers and such in the table itself, but I can’t for the life of me figure out where that stuff is stored. At least not in Windows.
Gregory: If you look in your ruby directory ( c:\ruby by default) and go down the tree until you get to the gems you’ll see the ajax scaffold generator gem. You can then look in the templates directory for the templates used during generation. If you want to modify those templates you should copy the whole generator directory into the /lib directory of your project and then modify it there.
Thanks Richard, and thanks for doing this. I had built something similar but it uses divs and isn’t scaffold based which made the whole process more of a pain than it needed to be
One thing that mind did that yours doesn’t is move all of these functions into a javascript block and pass in the controller and/or id that should be invoked. That way I didn’t have to duplicate that same code all over the place.
Richard, I’m loving your gem! I’ve got my forms cleaned up now and have been trying to figure out how to customize the list. Is there a clean way to modify the list? I’ve yet to find any instruction on it… I’m kind of assuming I’ll need to maniplate content_columns somehow – am I pointed the right direction? Are you aware of examples out there?
Gregory: Yeah I’m not sure how much more I can reduce the code size without using non-standard Rails tags. I am basically doing what you are referring to with all the callbacks for form_remote_tag and link_to_remote: passing in just the id stuff into a JS block. I’m not sure I could cut it down anymore without making it very difficult for users to modify, which is the whole point
David: Basically you generally, or at least I generally, don’t use content_columns after I’ve generated. They are good for the first run to make sure everything is working but then I fall back to actually explicitly specifying what columns should go where. I’ll write an article on how to do that today.
Great work! Doesn’t work 100% with Internet Explorer 7 (beta) though. The Edit/Delete and New buttosn gets messed upp a little.
Cheers,
joakmi
Joakim: Rest assured that when IE7 releases we’ll have all those bugs ironed out.
I’ll watch for the article on how to customize the lists. Eagerly! Thanks, David
Larry: I attempted to work in your taconite_for_prototype package into the 2.2.0 release and ran into some issues. I’d like to talk about them offline with you, drop me an email.
Like your gem a lot! But, not unlike some of the others I ran into a problem with content_colums in a ont-to-many situation. You said you’d write an article about that. Dit you ever do that?
Bertus: I have not written that article, it’s coming thought. Changing the columns for one-to-many associations is the same work for the AjaxScaffold as for the regular scaffold. So you might want to look up an tutorials on how to modify the normal Rails scaffolds as the procedure would be the same.
Looks good! In your example why did you repeat the ‘Widget’ name? I usually create scaffolds with just the table/object name:
ruby script/generate scaffold Car for example.
When I disabled JS on my browser to test degradation, the error message that short circuit the ‘new’ action by the render :inline method doesn’t works. It shows the form to create a new record. Also, I can simply visit http://localhost:3000/widget/new to access the form with JS activated.
Carlos: Ahhh thanks for pointing that out, I overlooked the error messages in my javascript testing. I’ll get on that. Yeah you can access /widget/new even with Javascript enabled, I’m not sure what the question is there?
Richard – just saw the customizing columns article and wanted to say thanks! I really like Ruby on Rails, but your ajax scaffold has sold me completely! I’m making plans to rewrite a couple of existing apps!
David: Awesome, glad you like it and good luck with the rewrites. Drop me a line if its anything publicly accessible.
This may be a question more related to general rails dev, but here goes. I have some existing scaffolds in a rails app that I generated with the built-in generator and customized. I’d like to replace with them with this. What’s the best way to do that? Should I generate new ones with this tool using a different name and then do a diff on the files? Thanks!
Simply fantastic. Greatly miss pagination and find though.
For some reason it doesnt work for me. Could it be because of this message i get after running generate ajax_scaffold ?
“undefined method `titleize’ for Inflector:Module”
Matt: Depends on whether you’ve highly modified the existing scaffold that you generated. If you have modified them you probably have only changed the form and the controller, so just save those and do a diff. Otherwise its probably much easier just to wipe it out the existing and replace as the diff would be a lot more work and prone to error.
Stuart: Pagination is certianly in the pipeline, and there is a way to get a somewhat suboptimal version of pagination working which I’ll document later on this week/weekend (If I don’t finish pagination by then).
Andrew: What version of Rails are you running?
Not sure what my version was but i updated it to the new one and it works like magic. Awesome. Thanks
Awesome tool! Just wanted to leave a quick note for those using a global application layout. When embeding in another page, be sure to add the javascript include (and stylesheet link tags) or things won’t work properly.
Mikey: Thanks for mentioning that, it reminded me that I need to add that into the howto.
A way to choose what columns to display easily would be nice too.
Aredridel: I have a new article that details what you have to do to change the columns. So you might want to check that out.
Richard, you said: “Yeah you can access /widget/new even with Javascript enabled, I’m not sure what the question is there?”. Ok, the question is… if you disabled the new action by short circuit the method with render :inline, is because you want to disable to the user the possibility of create a widget entry. So this method is not really valid to limit this to the user. Probably you must to modify the template also to show an error message.
Anon: Ah yes, this is an issue I’m currently working on: simplifying error messages that work in both JS and non-JS environments. I should have something out by the end of the weekend for that.
It’s a beautiful thing Richard, thank you! Just one question, though… I’m curious why you didn’t use the standard Rails URL format http://example.com/controller/action ? At least one other (besides me) user typed example.com/widgets/list and received unexpected results. (Not a criticism, just a question!)
Lester: I’m not quite sure I follow since I do use /controller/action (there really isn’t any other way to do it). Do you mean why is the controller named ‘widget’ and not ‘widgets’?
Richard, the url generated by the ajax scaffold for the list of widgets is http://www.example.com/widgets vs. what I would have expected: http://www.example.com/widgets/list. Now it’s true that there IS a result generated for http://www.example.com/widgets/list but it’s not a fully-formed web page, just a component (is that the correct term?). Did I make a mistake somewhere that caused this? I noticed that “David De-railed” did the same thing in an earlier comment. Thanks in advance for any clarification you can provide.
Lester: Ah, now I follow. Yeah the current view for list is the component which is rendered without a layout which is why it looks the way it does. A better convention probably would be to make list mirror index and then have a partial which is the current list. I’ll probably change that in the next version. Thanks for the heads up.
Wow! I’ve been wanting to look into AJAX for quite a while now, but never found the time to do so. With this generator and this really great blogpost I’ve made a kick start! Thanks!
Did you consider using RJS ?
Ovidiu: Someone else mentioned this in another thread, but I’ll address it here as well. Seeing how RJS is still only available in edge Rails it wasn’t even something I really considered at least for the first version. I will possibly migrate to RJS if I think it will make the scaffolds a lot easier to extend.
i dont know if this question belogs here, but anyway
how can i handle file uploads with ajax form? for now i’m using file_column plugin for uploading files. for uploading to work form must be posted with normal post. when posting with ajax form_remote_tag it is not working. of course it might be (and probably is) an issue with file_column
so i just wanna ask if there will be some support in ajax scaffold generator for uploading files. thanx.
WOW! This is some nice work that I am reaping the bennies from already. Have you seen the LiveTable demo over at Rico?
http://openrico.org/rico/livegrid.page
Could be a nice basis for the sortable tables.
viliks: Someone on this comment thread (or maybe the feedback one) mentioned another plugin which allows you to upload files using Ajax. The AjaxScaffold doesn’t cover this so it would be something you’d have to work in yourself.
Cameron: I have seen it, its been out for quite some time. My initial impression is that their solution is very heavyweight and would be hard for novices to modify. I think the last part is key for this since a generated scaffold is still designed to be modified by the end user.
This is excellent thanks. One additional suggestion is maybe to have an exclusion list that says to not generate input for certain columns, for instance created_on and modified_on are columns I use in all my tables (about 50 tables) and I need to go through and manually change all the forms right now to remove those, it would be nice to tell it to not generate the fields for those columns up front, especially as those are “special” fields anyway to rails.
Why when I try the render :inline => “Muwhahah! No new widget for you!”, :layout => false, :status => 500 trick in the def destroy method does nothing happen? even if I set the action to list or something that has a view? I have been trying all sorts of things to no avail. I need to return an error if I try to delete certain records. – thanks
If I install the gem, is there a way to modify the scaffold generator files? For example, if I want to change the css or any of the partials so that I do not have to make the same changes every time I generate the scaffold for a different model?
I guess the simplest thing would be to somehow run the ajax_scaffold_generator.rb from the .tgz file, but I’m new to rails and not sure how to do this. Would I have to make the changes, then gem everything, and install my version of the gem? Or is there a simpler way I can make changes to the files in the templates folder and just run something different than ./script/generate ajax_scaffold model_name?
kortina: If you copy the generator under /lib/generators you can then modify any of the code in there and when you generate it will use that version and not the gem installed one.
Jim: Currently the error messages don’t worry destroy. I am fixing that in the upcoming version. BTW sorry for the delay in my response.
Thanks for the response, Richard.
I found some links on the rails site that may be useful for anyone else who wants to use the generator and customize it:
http://wiki.rubyonrails.org/rails/pages/UnderstandingGenerators
http://wiki.rubyonrails.org/rails/pages/AvailableGenerators
Hi, would I use this same technique as you suggested for kortina to do the following?
I need to add this callback to all generated form_remote_tag and link_to_remote calls.
302 => “document.location = ‘/employees/login’”,
This properly handles a redirect to a login form. (The only way I could get to work so far).
It will be a pain to go through and manually add this to every generated occurence, but I need to do this as the login can expire, and clicking pretty much any button or link could cause a login redirect.
–Thanks
Could you document the use of the id= in the various places, I want to manually add a view, and I’m not quite sure how the ajax-scaffold scripts use these ids, like the form-#{tempid}-errors etc etc.
–thanks
This is very cool stuff, thanks! Really looking forward to the table sorting in a future release.
Once table sorting is implemented, I will be able to replace a C#/ASP.NET app at work with a Rails app with less than a day of labor.
This thing is working great except for two things:
1. When I use it in firefox on 10.4, everything looks great. However, when I use it with Safari, the link calls goto a new page, not a dropdown (basically, it looks like ajax is not being used…but I know it safari and ajax get along because I use it in all my other apps)
2. The generator doesnt’ work if there is already a migration in the db/migrate folder. WIth the changes to Rails 1.1 where a model is generates a migration, this might need to be cleaned up. (just a thought)
Generator does not appear to create any views or controllers. I have been googling for an answer to no avail.
I am on linux fedora core 5 and rails 1.1, and the latest ajax_scaffold_generator.
I just installed everything new. Anyone else seeing this?
Jason: Very odd that it sounds like its not using JS in Safari. A lot of people use the scaffolds in Safari and I thought everything was working a-okay in it. Let me know if you are still having those issues via email. The second point is very strange b/c my test application I use for the AjaxScaffold has migrations in it. Also doesn’t make any sense b/c the generator doesn’t even deal with migrations. Ahhh now I think I see the problem.. Rails 1.1. I haven’t tested the scaffold in 1.1 but I did have someone mention the new version of Effects.js breaks the scaffold. Rails 1.1 probably causes the other problems as well. The next version (this week) will be tested for 1.1.
David: It might be a Rails 1.1 issue, I have yet to test the generator at all in 1.1 since it just came out last week while I was on vacation. I’ll have it all working in Rails 1.1 with the new scaffold release this week.
Your Rails Ajax Scaffold is a very impressive & useful tool, thanks for making it public!
I have a question, maybe a suggestion for future feature!
Here is the scenario…
* Table of widgets with an expiry date
* I have a list view which included only unexpired widgets
* User clicks on Add widget and adds an expired widget
* The new widget is added to the top of the list
I want the user to be able to add the expired widget, but I do not want the widget to appear in the list.
A similar issue applied to editing, when an edit makes the widget expired, I want the edit saved, but the widget removed from the list.
I have tried adding a test in the update action and, if the new/edited widget is not eligible for inclusion in the list, render :nothing => true (as for delete)
However, I get an alert saying that both tags must be TR tags. After that, the result is what I wanted!
Any assistance, suggestions would be greatly appreciated
Nigel: I’ll first try and skirt your issue by proposing an alternate solution. Perhaps instead of not showing expired widgets you show them but add a class to the TR that is ‘expired’ and then you can modify the CSS so that the whole row is always grayed out. That seems like better user feedback instead of creating things that don’t appear. The reason you get that ‘tags must be TR tags’ is because the AjaxScaffold JS code is expecting a TR to be returned from an update call and nothing is returned. You can either remove that alert from AjaxScaffold.js or wrap the TableRow.MoveBefore() in AjaxScaffold.updateOnSuccess() in a try/catch.
Any word on the rails 1.1 issue? I am also having some troubles running the generator against my 1.1 project, simmilar to David above
heig: What is the error you are getting?
Richard: I don’t get any error at all, it seems to run but it dosen’t generate any models or views or anything that I can see. To be honest I’m a bit of a rails noob so maybe I’m missing something but I’m pretty sure I followed your directions correctly.
Very cool. Only problem I am experiencing (I’m using Rails 1.1) is that running “script/generate ajax_scaffold stuff ‘admin/stuffs’” results in a page with no AJAX. If I just use “script/generate ajax_scaffold stuff”, everything looks great. Just installed the generator today from gem, so should be latest version. Again, so very cool!
hieg: Very odd. If you can just hold tight until I get 3.0.0 out and see if that fixes things for you.
Terry: Yeah I haven’t patched the latest version (2.2.1) for Rails 1.1 at all so mileage may vary. 3.0.0’s release is imminent and is designed for 1.1.
First off, this is an awesome plugin!! I have the same question as viliks. Do you plan to support picture/file uploads. It would be great if you could use: file_column plugin or sean treadwell’s upload progress plugin with AJAX_SCAFFOLD
Thanks
Hi guys,
ajax_scaffold is a really nice thing, but today i updated to 3.0.4
ajax_scaffold_generator (3.0.4, 3.0.1, 2.2.1)
Ajax scaffold generator is a rails generator for ajaxified scaffolds
well but since that i get a bunch of errors on almost every page.
I also tried on several other boxes of mine an on none of them the new one worked right
Anyways it is a great project
Franz: Can you track down any specific issues you are having via log output or Javascript Console output? Was a previous version of the scaffolding working for you? Email me or put any info you have on the bugs site and hopefully we can get that resolved.
This just isn’t working. I get the main layout but only the delete button works. Create and edit do nothing… ARGGH
JReading: If you post over on the forum some more specifics about what problems you are having (errors in the log etc). We’ll be happy to help you out.
Natural Herbalz – We Care Your Health
An America’s Best Online Natural herbal health care products Review Store On Mens and Womens health, Skin Care, General Health, Sexual Health, Hair Care, Weight loss and More Health Care products, Treatments, Articles and Information. http://www.naturalherbalz.com