Uday kumar das
Uday kumar das

Reputation: 91

undefined local variable or method `subjects_path'

I want to search text from mysql db table .

view page:

<% form_tag subjects_path, :method => :get do %>
  <p>
    <%= text_field_tag :search, params[:search] %>
    <%= submit_tag "Search", :name => nil %>
  </p>
<% end %>

controller code:

  before_action :confirm_logged_in

  def index
    @subjects=Subject.sorted   
     @subjects = Subject.search params[:search]
  end'

Routes used:

 root 'demo#index'

  get 'admin', :to=> "access#index"

  match ':controller(/:action(/:id))' ,:via=>[:get,:post]  

i am waiting for your answer.

Upvotes: 1

Views: 90

Answers (1)

j-dexx
j-dexx

Reputation: 10416

in routes.rb you need to define the subjects

resources :subjects, only: [:index]

You've not specified any named routes so subjects_path doesn't exist.

Upvotes: 4

Related Questions