Forum: Ruby on Rails Couldn't find without an ID

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A3ae9f39c4b2fd0fa048bfa43ca2a495?d=identicon&s=25 Thiti Panya (plemazako)
on 2009-03-25 03:42
(Received via mailing list)
hello ,
i have problem when i want to show page after user submit data into
database.
 this is code in controller
>>>
class ComponentsController < ApplicationController

  def index
  end

  def databases
    @title = "Database"
    if request.post?and params[:seq]
      params[:seq][:sequence].gsub!(/\s/,"")
      params[:seq][:sequence].upcase!
      @seq = Seq.new(params[:seq])
      if @seq.save
        flash[:notice] = "sequence submitted !"
        redirect_to  :action => "show"
      end
    end
  end

  def show
    @title = "Show"
    @seq = Seq.find(params[:id])
    end
  end
end

>>when i run i have error like is
ActiveRecord::RecordNotFound in ComponentsController#show
Couldn't find Seq without an ID
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
base.rb:1572:in `find_from_ids'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
base.rb:616:in `find'
/home/apple/www/rcc_eri/app/controllers/components_controller.rb:29:in
`show'
2b1df44ef63bbf410976ef082d0d5d8b?d=identicon&s=25 Yacobus Reinhart (malioboro)
on 2009-03-25 04:27
it is not
> redirect_to  :action => "show"

BUT :
redirect_to  :action => "show", :id => @seq.id

Good Luck,
Reinhart
company : be-barefoot.com

Thiti Panya wrote:
> hello ,
> i have problem when i want to show page after user submit data into
> database.
>  this is code in controller
>>>>
> class ComponentsController < ApplicationController
>
>   def index
>   end
>
>   def databases
>     @title = "Database"
>     if request.post?and params[:seq]
>       params[:seq][:sequence].gsub!(/\s/,"")
>       params[:seq][:sequence].upcase!
>       @seq = Seq.new(params[:seq])
>       if @seq.save
>         flash[:notice] = "sequence submitted !"
>         redirect_to  :action => "show"
>       end
>     end
>   end
>
>   def show
>     @title = "Show"
>     @seq = Seq.find(params[:id])
>     end
>   end
> end
>
>>>when i run i have error like is
> ActiveRecord::RecordNotFound in ComponentsController#show
> Couldn't find Seq without an ID
> /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:1572:in `find_from_ids'
> /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/
> base.rb:616:in `find'
> /home/apple/www/rcc_eri/app/controllers/components_controller.rb:29:in
> `show'
A3ae9f39c4b2fd0fa048bfa43ca2a495?d=identicon&s=25 Thiti Panya (plemazako)
on 2009-03-25 04:44
(Received via mailing list)
thank you very much Reinhart
it' work. -___-

2009/3/25 Rails Terrorist <rails-mailing-list@andreas-s.net>
This topic is locked and can not be replied to.