Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
newbie: Rails deliberations
peter.cutting
2/2/2005 3:41:00 PM
I have alot of questions and (daft) opinions which I will place in this
thread and hopefully I will get some answers. Thanks alot. Peter
1) is the "list" really necessary in the following code example taken
from
http://dev.rubyonrails.org/svn/rails/trunk/actionpack/lib/action_controller/scaf...
# def list
# @entries = Entry.find_all
# render_scaffold "list"
# end
2) It would be nice if the command
ruby script\generate scaffold <model>
also embedded comments in the generated code which described what name
is what how the name variations are related to one another. Superfluous
for the experts, I know. But since the code is so tight already why not
give the newbies some help
3) 2) is especially important since the naming is a bit of nightmare.
eg all sorts of implicit messing around with leading capitals,
camelcase, underscores, pluralisations, and other (eg person->people)
transformations going on. This is all very difficult for mere mortals
(with shitty memories) to grok
4) what is going on with new and create. Do they work togeather. If so
how?
(example taken from same place as above)
# def new
# @entry = Entry.new
# render_scaffold
# end
#
# def create
# @entry = Entry.new(@params["entry"])
# if @entry.save
# flash["notice"] = "Entry was succesfully created"
# redirect_to :action => "list"
# else
# render "entry/new"
# end
# end
5) What is going on in the generated edit view template?
<%= error_messages_for 'project' %>
<%= form 'project', :action => 'update' %>
The error_messages_for bit I dont understand at all.
Editing a record initiates the edit action which which default renders
the edit view which seems to (based on the above) start of a update
action ??? and now I am lost
6) the list template scaffolding iterates thru columns. Wouldnt it be
better to inline the columns since they will almost certainly be
customised later. A lot easier to read and mess about with. (the
iterated alternative could also be included but switched off and the
developer could then quickly switch it on to see all the available
columns).
<% for project in @projects %>
<tr>
<% for column in Project.content_columns %>
<td><%=h project[column.name] %></td>
Thats enough for now.
2 Answers
ruby talk
2/2/2005 6:05:00 PM
0
On Thu, 3 Feb 2005 00:45:48 +0900, peter.cutting@tetrapak.com
<peter.cutting@tetrapak.com> wrote:
> I have alot of questions and (daft) opinions which I will place in this
> thread and hopefully I will get some answers. Thanks alot. Peter
I don't mean to discourage you from posting Rails questions here, but
have you asked these questions on the Rails mailing list?
http://lists.rubyonrails.org/mailman/list...
It seems many of your questions are about Rails' design decisions and
implementation details, and I think you would get better, faster
answers on the Rails list.
James
Eric Hodel
2/2/2005 7:11:00 PM
0
On 02 Feb 2005, at 07:45, peter.cutting@tetrapak.com wrote:
> I have alot of questions and (daft) opinions which I will place in this
> thread and hopefully I will get some answers. Thanks alot. Peter
>
> 1) is the "list" really necessary in the following code example taken
> from
>
http://dev.rubyonrails.org/svn/rails/trunk/actio...
> action_controller/scaffolding.rb
> # def list
> # @entries = Entry.find_all
> # render_scaffold "list"
> # end
Yes.
It would be more code to 'guess' which scaffold you wanted from caller.
And it would also get in your way more than you like.
> 2) It would be nice if the command
> ruby script\generate scaffold <model>
> also embedded comments in the generated code which described what name
> is what how the name variations are related to one another. Superfluous
> for the experts, I know. But since the code is so tight already why not
> give the newbies some help
Have you read anything from
http://api.rubyon...
Lots of this
code is very well described there.
> 3) 2) is especially important since the naming is a bit of nightmare.
> eg all sorts of implicit messing around with leading capitals,
> camelcase, underscores, pluralisations, and other (eg person->people)
> transformations going on. This is all very difficult for mere mortals
> (with shitty memories) to grok
Have you read:
http://rails.rubyonrails.com/files/vendor/actionpack/R...
http://rails.rubyonrails.com/files/vendor/activerecord/R...
> 4) what is going on with new and create. Do they work togeather. If so
> how?
> (example taken from same place as above)
> # def new
> # @entry = Entry.new
> # render_scaffold
> # end
> #
> # def create
> # @entry = Entry.new(@params["entry"])
> # if @entry.save
> # flash["notice"] = "Entry was succesfully created"
> # redirect_to :action => "list"
> # else
> # render "entry/new"
> # end
> # end
ActionController methods are 'actions'...
> 5) What is going on in the generated edit view template?
> <%= error_messages_for 'project' %>
> <%= form 'project', :action => 'update' %>
So this form will be sent to the 'update' action of the current
controller.
> The error_messages_for bit I dont understand at all.
Well documented on
http://api.rubyo...
:
http://rails.rubyonrails.com/classes/ActionVie...
ActiveRecordHelper.html#M000236
> Editing a record initiates the edit action which which default renders
> the edit view which seems to (based on the above) start of a update
> action ??? and now I am lost
When you submit the form, yes. See the documentation for #url_for,
which is how Rails generates URLs:
http://rails.rubyonrails.com/classes/ActionController/Base.ht...
> 6) the list template scaffolding iterates thru columns. Wouldnt it be
> better to inline the columns since they will almost certainly be
> customised later. A lot easier to read and mess about with. (the
> iterated alternative could also be included but switched off and the
> developer could then quickly switch it on to see all the available
> columns).
Sure, go nuts!
Just displaying the columns is 'good enough' because the second thing I
do after adding a scaffolded controller is rip away all the scaffolding
and build something sensible with only the columns I need. (The first
being adding some good data to play with.)
Rails does all the heavy lifting you don't want to do, and leaves you
to do the heavy lifting you *should* be doing.
--
Eric Hodel - drbrain@segment7.net -
http://se...
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
newbie: Rails deliberations
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password