(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 method
controller:
def random # method works checked it in the console. Returns a valid obj. @task = Task.find(rand(Task.first.id..Task.last.id)) render "random" end
random.html.erb <%= @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:in `redirect_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:in `block 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:in `instrument' 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:in `send_action' actionpack (3.2.3) lib/abstract_controller/base.rb:167:in `process_action' . . . (only the top of the stack)
Request
Parameters:
{"id"=>"random"}