Cannot redirect to nil! - basic MVC operation

(I’m having some hard time for days to manage to chose a random item
from teh database and to be able to pass it further.)

It is basic operation and i tried several ways all, brought me to the
same problem, params {“id” = “random”} <- the name of the controller


def random # method works checked it in the console. Returns a valid
@task = Task.find(rand(…
render “random”

<%= @task %> # i want it to make it work, if i pass manually
lets #say ../random/1 lets say as an example it works it shows me the
memory #location of the object.

error log:

ActionController::ActionControllerError in TasksController#show
Cannot redirect to nil!

Rails.root: /home/bogdan/ex/bored
Application Trace | Framework Trace | Full Trace

actionpack (3.2.3) lib/action_controller/metal/redirecting.rb:60:in
redirect_to' actionpack (3.2.3) lib/action_controller/metal/flash.rb:25:inredirect_to’
actionpack (3.2.3) lib/action_controller/metal/instrumentation.rb:60:in
block in redirect_to' activesupport (3.2.3) lib/active_support/notifications.rb:123:inblock
in instrument’
activesupport (3.2.3)
lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (3.2.3) lib/active_support/notifications.rb:123:ininstrument’
actionpack (3.2.3) lib/action_controller/metal/instrumentation.rb:59:in
redirect_to' actionpack (3.2.3) lib/action_controller/metal/implicit_render.rb:4:insend_action’
actionpack (3.2.3) lib/abstract_controller/base.rb:167:in
(only the top of the stack)




On Mon, Sep 17, 2012 at 9:31 AM, Bogdan M. [email protected] wrote:

memory #location of the object.
@task.inspect would be more useful, or actually displaying some
specific attributes of the object :slight_smile:

error log:

ActionController::ActionControllerError in TasksController#show
Cannot redirect to nil!

But here, you’re not even using your “random” method, you’re calling
“show” – check your routes.

Hassan S. ------------------------ [email protected]
twitter: @hassan

well you are not using rest routes.
it should look like :
rails would understand 4 as the param .

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