Tyler
Tyler

Reputation: 2386

Ruby on rails no method error

Ok so I am getting a no method error from this line of code

  <%= form_for(@comment) do |f| %>

The issue I think stems from my routes that look like this

  namespace :api do
    namespace :v1 do
    resources :comments do
      collection do
        get "by_user_id"
      end
    end
  end
  end

I am creating an api but in order to test it I wanted to have the scaffolding forms etc there... is there a way to make these forms work?

Upvotes: 0

Views: 51

Answers (1)

BroiSatse
BroiSatse

Reputation: 44675

Assuming @comment is not nil, this should work:

<%= form_for([:api, :v1, @comment]) do |f| %>

Upvotes: 2

Related Questions