Hi, I was looking for some clarification so I can conceptually wrap my
head around this concept:
in the lab 11, the comment form passes information back to the
post_comment method
def post_comment
@comment = Comment.new(.... "comment" => params[:comment]
['comment'])
...
end
the form code mapping to this controller action is:
<% form_tag :action => 'post_comment' do #>
<%= text_area 'comment', 'comment' %>
<%= submit_tag "post" %>
so when the submit button is pressed, it wraps up the params and sends
it to the post_comment method, that much I get from the lab
discussion:
"The Rails framework passes the submitted parameters from the page as
a hash (params[:comment]), from which the code pulls out the comment
parameter through params[:comment]['comment'] - the [:comment]
represents Comment model while ['comment'] represents comment field of
the Comment model."
To me this suggests that the hash returning from the form is already
of the model type Comment (last sentence) "the [:comment] represents
Comment model while ['comment'] represents comment field of the
Comment model.".
On the rails documentation the following example is given:
<% form_for :person, @person, :url => { :action => "create" } do |f|
%>
<%= f.text_field :first_name %>
<%= f.text_field :last_name %>
<%= submit_tag 'Create' %>
<% end %>
which passes the symbol associated with the model field name using the
form_for helper method. I understand this better than 'comment'
'comment'. Obviously rails knows whats going on, but I dont. Anyone
want to clarify?
Thanks,
jed
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
ruby-on-rails-programming-with-passion-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---