I hope you enjoyed my DeveloperWorks article on ActiveScaffold 1.0. If you have questions or comments about the article or related technologies, please feel free to post them here!
Errata
- The current_user_method configuration in Listing 22 is incorrect. That config.security… line needs to go into the global configuration in app/controllers/application.rb along with the current_user method.
- The csv_header class method in Listing 19 needs to escape the double quotes around ID: “\”ID\”,Last Name,First Name,Email,Birthdate”
18 responses so far ↓
1 physio // Jun 14, 2007 at 11:05 am
Hi Mike…
Thanks for the great tutorial. I’ve been struggling with AS; the documentation is quite minimal. One thing your article didn’t discuss was how to add a custom nested link. I want a link with each row that will simply display a partial and not have to call a completely different controller.
Is this somehow possible? I can’t figure out how.
2 mperham // Jun 14, 2007 at 12:23 pm
You could try adding a column to the list:
config.list.columns.add :fake
and then add a helper for that column in your helper:
def fake_column(record)
“this is a fake column”
end
This is a pretty bad hack though. You might ask on the AS mailing list and see if anyone has a better suggestion.
3 ofi // Jun 23, 2007 at 1:41 pm
Hello Mike,
thanks a lot for this article which helped me especially on the localization subject. For others who may fiddle like I did with their .po files of gettext until they figured out the missing line, I’d like to send a snippet of application.rb’s tail:
class Object
include GetText
bindtextdomain(”domain”) # THIS ONE!
def as_(*args)
_(*args)
end
end
Cheers [ofi]
4 sergio // Aug 8, 2007 at 3:14 am
dear mike,
thank you for the nice tutorial, it is really filling a gap.
my little experience gives me a problem with your suggestion for the to_label method: i get a
uninitialized constant Person::NAME
when i use NAME (a column in the table) as the label.
could you tell me what i am failing to do?
thank you!!
5 mperham // Aug 8, 2007 at 6:32 am
Sergio, this isn’t really the appropriate place to help with typical Ruby problems. You might post your source on the ActiveScaffold mailing list and see if someone can help you there.
6 Grant // Aug 31, 2007 at 1:34 am
I also found your article very helpful. The part I am trying to figure out is how migrations work in AS.
I created a table with a migration and then used ActiveScaffold to have it quickly show up on my page. I then added another table and an extra field to the first table (foreign key - “user_id”) into the next iteration of my migration. After doing this the new information does not show up in the AS Page with the new field (”user_id”) column. Is it hidden by default? Is there a way to force it’s visibility? How can I get the subforms to show up so I could change the user in the original table?
Thank you for your insight,
Grant
7 mperham // Aug 31, 2007 at 6:40 am
Grant, have you added an association in the model, e.g. “belongs_to :user”?
8 mcr // Oct 6, 2007 at 5:16 pm
the model listing on the article seems incomplete. many relationships are not defined. The source code has the right version
9 mperham // Oct 6, 2007 at 5:20 pm
mcr, the code listing in the text is not meant to be canonical, just illustrate the topics described in the text.
10 kalaiselvan // Oct 30, 2007 at 1:57 am
i’m using AS for my project - where i’m finding it difficult to do the following
1. in query screen how do I add drop down values pulled from DB?
2. how to add image file upload in create/update screen using AS
can anyone explain this with examples striclttly using AS? thanks
11 Ricardo // Nov 13, 2007 at 5:21 pm
Dear Mike,
Great article!
Is there any way to have multiple models scaffolded in the same controller?
Best regards, RIcardo
12 mperham // Nov 13, 2007 at 5:34 pm
@Ricardo, the only thing I know of like that are embedded scaffolds:
http://activescaffold.com/tutorials/embedded
13 hfwu // Dec 14, 2007 at 1:44 am
ActiveScaffold is a greate rails plugin.
But i have some trouble when i use it.
I looked for the ways to upload file or image but fail to do it. Any ways?
14 wpd // Mar 12, 2008 at 6:27 am
Thanks for the tutorial. I’m trying to understand action links, and I have a few questions from your article. I am brand new to RoR, so please bear with me…
1) In your csv_header method, should the header line be encased in single quotation marks instead of double quotation marks? Alternatively, should the quotation marks surrounding the ID field be escaped? (I got syntax errors otherwise, in my RoR 2.0.2 installation.)
2) On Rails 2.0.2, should there be some routing magic performed in order to get to the export_csv method? Following your example, I got:
ActiveRecord::RecordNotFound in DocumentsController#show
Couldn’t find Document with ID=export_csv
From what I’ve read about the routing mechanism, and RESTful rails, I can see why I’m getting this error. I’m just not sure what the “best” method is to work around it. So I added the following to config/routes.rb:
map.connect ‘documents/export_csv’, :controller => ‘documents’, :action => ‘export_csv’
Note that I had to add it _before_ my “map.resources” line, so that it would match first. It feels like I’m typing the same 2 things a lot (”documents” and “export_csv”), so I wonder if I’m not being as DRY as I could be.
Is there a simpler way to connect the link to an action in my controller? I tried specifying :controller and :action in the conf.action_links.add line, but that didn’t help.
3) This aims me in the direction that I want to go, which is that I would like to have a drop down menu to narrow the view of my table down based on specific categories of records in my table. Can you give me any pointers on how I might do that? I would like the user to select a category from the drop down menu and filter the results displayed based on the category. Ideally, I would like the display to update immediately, which I think means AJAX, but, as I said, I’m still learning.
Again, thank you for the time and effort you put into your tutorial. I hope my documentation of my attempt try the action links part on RoR 2.0.2 will help more than it will hinder somebody else going down this road.
–wpd
15 mperham // Mar 12, 2008 at 12:15 pm
1) Yes, good catch.
2) The article was written pre-REST. Routing in Rails 2.0 is very much biased towards RESTful routing so this code won’t work very well on 2.0. Since CSV is just a format, we really should be using responds_to with a file extension on the URL to “route” to the CSV formatter, like “/documents/123.csv”.
3) Sorry I can’t help you here. I haven’t used AS since the article was published so I’ve lost most of my AS mojo! I’m sure the mailing list can help here.
16 güvenlik sistemleri // Apr 14, 2008 at 6:54 am
thanks this article
17 sanders // May 16, 2008 at 12:36 am
Thanks this article, I follow the example, when I create a project or user, it is display “[Request Failed (code 500, Internal Error)]“. I donot know why ?can you tell me the reason?
18 health // Aug 13, 2008 at 2:27 pm
thanks for the article