Hi,
I use scaffold to create the task model controller and view, it
contains action as "show", "new", "create", etc.
Then, I give an "id" parameters to the view - new.rhtml, so the URL
could be like "http://localhost:3000/tasks/new/1" , and I wish when I
click the create button in "new.rhtml", the following
"create" action
could get this id parameter, so I coded like this:
==============def create
@task = Comment.new(params[:task])
respond_to do |format|
s = params[:id] # I wanna obtain the id
parameter here
puts ''this is s'' + s
......
.....
==================
However, it gives me the error as :
==================can''t convert nil into String
{"commit"=>"Create",
"authenticity_token"=>"ae9620b7a5388f218e783889095d1aa4249cfe30",
"comment"=>{"author"=>"222",
"desc"=>"2",
"img_url"=>"2"}}
====================
how can I get the id from "new.rhtml" ''s URL and use it in
create
action?
also attach my new.rhtml
===============<% form_for(@task) do |f| %>
<p>
<b>Author</b><br />
<%= f.text_field :author %>
</p>
<p>
<b>Desc</b><br />
<%= f.text_area :desc %>
</p>
<p>
<b>Img url</b><br />
<%= f.text_field :img_url %>
</p>
<p>
<%= f.submit "Create" %>
</p>
<% end %>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---