When using scaffold flash['notice']

Hi,

When using the scaffold standard new / create methods, on successful
completion of creating a new database entry, is there any return
methods I cna pick up in a custom tempalte such as flash[‘notice’]?

Thanks
Scott

ss wrote:

Hi,

When using the scaffold standard new / create methods, on successful
completion of creating a new database entry, is there any return
methods I cna pick up in a custom tempalte such as flash[‘notice’]?

Thanks
Scott

I’m not sure what your are asking but the flash is exactly how you send
data to the next action. And the flash is just a standard hash that you
can fill with any keys you like.

flash[:array] = [1, 2, 3]
flash[:model] = BlogComment.find(123)
flash[:error_message] = ‘Comment not saved due to an ugly error!’

If thats not what you were askign about to asking your question again as
it is a bit unclear.

ok maybe it was a bit unclear.

When I create a custom template / def I can specify somthing like this
in my controller

flash[‘notice’] = “Client successfully removed”

and then use this in my rhtml, to show the message

<% if flash[‘notice’] %>

<%= flash[‘notice’]%>

<% end %>

When I havnt got any custom def’s in my controller and am just using the
standard scaffold templates.

ie ‘scaffold :clients’ in my controller

Does it return any successful messages when an operation like create or
destroy has worked correctly, and how can I get hold of these?

ss wrote:

ok maybe it was a bit unclear.

When I create a custom template / def I can specify somthing like this
in my controller

flash[‘notice’] = “Client successfully removed”

and then use this in my rhtml, to show the message

<% if flash[‘notice’] %>

<%= flash[‘notice’]%>

<% end %>

When I havnt got any custom def’s in my controller and am just using the
standard scaffold templates.

ie ‘scaffold :clients’ in my controller

Does it return any successful messages when an operation like create or
destroy has worked correctly, and how can I get hold of these?

Oh I see, Well you’re moving beyond the capabilites of scaffold here.
Scaffold is meant to be a quick and dirty start, but not something you
finish with. Run this:

ruby script/generate scaffold Clients Client

This actually creates all the scaffold code and rhtml templates so you
can edit them. Then you can go into the create and update methods and
get the hooks you need. Making the base scaffold work for anything even
slightly complicated will only end in frustration. Use it as a
srpingboard to modify and update.

But directly answering your question, the only response scaffold gives
about success is the flash. And if the data is good, it does a
redirect, and if its bad it does a render. Scaffold wasn;t really meant
for anything more complicted than that.

Bill W. wrote:

Just as a heads-up…

ruby script/generate scaffold Clients Client

The above will generate a model named clients.rb. That will probably
give
you problems down the road since the Rails naming conventions assume
that a
model’s name will be the singular of the table name on which it is
based. I
imagine that was just a typo, but it’s caught me before so I thought I’d
point it out before you got too far down the road.

Best regards,
Bill

Yeah my bad, it should be

ruby script/generate scaffold Client Clients

The first parameter is the model name, and the second parameter is the
controller name, I get them confused sometimes.

Yeah my bad, it should be

ruby script/generate scaffold Client Clients

The first parameter is the model name, and the second parameter is the
controller name, I get them confused sometimes.

ok cool, thanks

Just as a heads-up…

ruby script/generate scaffold Clients Client

The above will generate a model named clients.rb. That will probably
give
you problems down the road since the Rails naming conventions assume
that a
model’s name will be the singular of the table name on which it is
based. I
imagine that was just a typo, but it’s caught me before so I thought I’d
point it out before you got too far down the road.

Best regards,
Bill