Guest User

Untitled

a guest
Apr 26th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1.  
  2. class Question < ActiveRecord::Base
  3.  
  4. belongs_to :bundle
  5. has_many :options
  6. has_many :votes
  7.  
  8. end
  9.  
  10.  
  11. class Bundle < ActiveRecord::Base
  12.  
  13. has_many :questions
  14.  
  15. end
  16.  
  17.  
  18.  
  19. BundlesController
  20.  
  21. def show
  22.  
  23. #check it exists first
  24.  
  25. if Bundle.exists?(params[:id])
  26.  
  27. @bundle = Bundle.find(params[:id])
  28. @question = @bundle.questions.first # because there is only one question in this test #### THIS IS ERROR HERE
  29. @options = @question.options
  30. logger.info(@bundle.id)
  31. logger.info(@question.text)
  32. @options.each do |o|
  33. logger.info(o.text)
  34. end
  35. respond_to do |format|
  36. format.html # show.html.erb
  37. format.xml { render :action => :show }
  38. end
  39. else
  40. respond_to do |format|
  41. format.html { redirect_to :index }
  42. format.xml { render :text => 'ERROR!' }
  43. end
  44. end
  45.  
  46. end
Add Comment
Please, Sign In to add comment