The parameter is nil?

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| %>

Author
<%= f.text_field :author %>

Desc
<%= f.text_area :desc %>

Img url
<%= f.text_field :img_url %>

<%= f.submit "Create" %>

<% end %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs