Note that there are some explanatory texts on larger screens.

plurals
  1. PORails routes issue, undefined '******_path' with form_for
    primarykey
    data
    text
    <p>So, I'm new to rails, and I'm building an app that will need to be versioned. My question is very similar to <a href="https://stackoverflow.com/questions/8706774/undefined-method-with-path-while-using-rails-form-for">this question</a>, however, trying the given solutions to that have not resolved my issue.</p> <p>Here's the error I get:</p> <pre><code>ActionView::Template::Error (undefined method `questions_path' for #&lt;#&lt;Class:0x000000057bd2c0&gt;:0x000000057b00e8&gt;) </code></pre> <p>here is my view:</p> <pre><code>&lt;h1&gt;Create Question &lt;/h1&gt; &lt;%= form_for(@question) do |f| %&gt; &lt;div&gt; &lt;%= f.label :text %&gt; &lt;%= f.text_field :text %&gt; &lt;/div&gt; &lt;div class="actions"&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>here is my controller:</p> <pre><code>class Api::V1::QuestionsController &lt; Api::V1::ApiController inherit_resources load_and_authorize_resource :user load_and_authorize_resource :through =&gt; :user def index respond_with @questions.unanswered(current_user) end def new @question = Question.new end def create @question = Question.new(params[:question]) if @question.save #render :action =&gt; 'new' else puts @question.text puts @question.level puts @question.answers.inspect end end #other methods... end </code></pre> <p>and finally, the current version of my routes:</p> <pre><code> namespace :api, :defaults =&gt; { :format =&gt; 'json' } do namespace :v1 do resources :users do resources :questions, :path =&gt; 'questions' do collection do #get 'new', :to =&gt; 'questions#new', :as =&gt; :new_api_v1_user_question_path end end end resources :questions, :path =&gt; 'questions' do resources :answers do resources :responses end collection do #get 'new', :to =&gt; 'questions#new', :as =&gt; :new_api_v1_question_path end end end end match 'api/v1/user/:user_id/questions/new.html', :to =&gt; 'api/v1/user/:user_id/questions#new', :as =&gt; :new_api_v1_user_question </code></pre> <p>Basically, I don't know how to do the solution from <a href="https://stackoverflow.com/questions/8706774/undefined-method-with-path-while-using-rails-form-for">that other question</a> with the namespace stuff I'm doing. As you can see, I've tried using match, I've commented out where I tried using resources and 'collection,' but no dice. I've mixed and matched all kinds of things, and either it gives me the error I've described here, or a "route doesn't exist" error. I've even looked at the <a href="http://guides.rubyonrails.org/routing.html" rel="nofollow noreferrer">rails guides on routing</a>, but to no avail. Struggled with it for days. Please help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload