ga-dc / wdi5-project3

Project 3
0 stars 5 forks source link

ArgumentError in Languages#index #90

Closed chadxsmith closed 9 years ago

chadxsmith commented 9 years ago

When attempting to transform my JQuery autocomplete component into a rails form helper, I keep seeing "ArgumentError in Languages#index". I think the errors related to my @question_query variable being null, according to Stack Overflow

Code below:

(View) Application <%= form_for @question_query do |f| %>

      <div class="ui-widget">
        <label for="tags"></label>
        <input type="text" id="tags">
      </div>

  <%= f.submit%>

  <% end %>

(Controllers) Languages

def index
    @languages = Language.all
    @topics = Topic.all
    @questions = Question.all
    @answers = Answer.all
    @question_query = params[:question]

    @everything = []
    @question_info = @questions.map {|q| [ q.title, language_topic_question_path(Language.first, q.topic, q)]   }
    # [q1, q2]
    # [["How do I..", "/languages/12/topics/2/question/1"], ["Should I..", "/languages/12/topics/4/question/2"]    ]

    respond_to do |format|
      format.html { render :index}
      format.json { render json: @question_info}
    end
end

(Controllers) Search

class SearchController < ApplicationController

  def index
    @question_query = params[:question]
    @questions = Question.all
  end

end