Problem With Blacklight Catalog Routes

Hi, I’m starting my first ruby on rails app featuring blacklight with solr. I can install and loginto the solr blacklight server on port 8983, but I can’t seem to access localhost:3000. It appears to be a routing issue. When I try to access localhost:3000 here is what I get…

Routing Error

No route matches [GET] “/catalog”

Rails.root: /home/*/railsfiles/search_app

I’ve tried adding routes to no avail. Here is the contents of my routes.rb file as it came installed by default with your project setup plus my addition of the get: catalog route.

Can you help?

Rails.application.routes.draw do

mount Blacklight::Engine => ‘/’

root to: “catalog#index”

devise_for :users

concern :exportable, Blacklight::Routes::Exportable.new

resources :solr_documents, only: [:show], path: ‘/catalog’, controller: 'cata$

concerns :exportable

end

resource :static_pages do

collection do

get :catalog

end

end

resources :bookmarks do

concerns :exportable

collection do

delete ‘clear’

end

end

For details on the DSL available within this file, see http://guides.rubyon$

end

Dane

Never heard of Blacklight but the first obvious questions are

versions of Ruby | Rails | Blacklight ? output of `rake routes` ?

Here is the output

rake routes

Prefix Verb URI Pattern Controller#Action

blacklight / Blacklight::Engine

root GET / catalog#index

new_user_session GET /users/sign_in(.:format) devise/sessions#new

user_session POST /users/sign_in(.:format) devise/sessions#create

destroy_user_session GET /users/sign_out(.:format) devise/sessions#destroy

new_user_password GET /users/password/new(.:format) devise/passwords#new

edit_user_password GET /users/password/edit(.:format) devise/passwords#edit

user_password PATCH /users/password(.:format) devise/passwords#update

PUT /users/password(.:format) devise/passwords#update

POST /users/password(.:format) devise/passwords#create

cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel

new_user_registration GET /users/sign_up(.:format) devise/registrations#new

edit_user_registration GET /users/edit(.:format) devise/registrations#edit

user_registration PATCH /users(.:format) devise/registrations#update

PUT /users(.:format) devise/registrations#update

DELETE /users(.:format) devise/registrations#destroy

POST /users(.:format) devise/registrations#create

email_solr_document GET|POST /catalog/:id/email(.:format) catalog#email

sms_solr_document GET|POST /catalog/:id/sms(.:format) catalog#sms

citation_solr_document GET /catalog/:id/citation(.:format) catalog#citation

email_solr_documents GET|POST /catalog/email(.:format) catalog#email

sms_solr_documents GET|POST /catalog/sms(.:format) catalog#sms

citation_solr_documents GET /catalog/citation(.:format) catalog#citation

solr_document GET /catalog/:id(.:format) catalog#show

catalog_static_pages GET /static_pages/catalog(.:format) static_pages#catalog

new_static_pages GET /static_pages/new(.:format) static_pages#new

edit_static_pages GET /static_pages/edit(.:format) static_pages#edit

static_pages GET /static_pages(.:format) static_pages#show

PATCH /static_pages(.:format) static_pages#update

PUT /static_pages(.:format) static_pages#update

DELETE /static_pages(.:format) static_pages#destroy

POST /static_pages(.:format) static_pages#create

email_bookmark GET|POST /bookmarks/:id/email(.:format) bookmarks#email

sms_bookmark GET|POST /bookmarks/:id/sms(.:format) bookmarks#sms

citation_bookmark GET /bookmarks/:id/citation(.:format) bookmarks#citation

email_bookmarks GET|POST /bookmarks/email(.:format) bookmarks#email

sms_bookmarks GET|POST /bookmarks/sms(.:format) bookmarks#sms

citation_bookmarks GET /bookmarks/citation(.:format) bookmarks#citation

clear_bookmarks DELETE /bookmarks/clear(.:format) bookmarks#clear

bookmarks GET /bookmarks(.:format) bookmarks#index

POST /bookmarks(.:format) bookmarks#create

new_bookmark GET /bookmarks/new(.:format) bookmarks#new

edit_bookmark GET /bookmarks/:id/edit(.:format) bookmarks#edit

bookmark GET /bookmarks/:id(.:format) bookmarks#show

PATCH /bookmarks/:id(.:format) bookmarks#update

PUT /bookmarks/:id(.:format) bookmarks#update

DELETE /bookmarks/:id(.:format) bookmarks#destroy

rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show

rails_blob_variation GET /rails/active_storage/variants/:signed_blob_id/:variation_key/*filename(.:format) active_storage/variants#show

rails_blob_preview GET /rails/active_storage/previews/:signed_blob_id/:variation_key/*filename(.:format) active_storage/previews#show

rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show

update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update

rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create

Routes for Blacklight::Engine:

search_history GET /search_history(.:format) search_history#index

clear_search_history DELETE /search_history/clear(.:format) search_history#clear

clear_saved_searches DELETE /saved_searches/clear(.:format) saved_searches#clear

saved_searches GET /saved_searches(.:format) saved_searches#index

save_search PUT /saved_searches/save/:id(.:format) saved_searches#save

forget_search DELETE /saved_searches/forget/:id(.:format) saved_searches#forget

POST /saved_searches/forget/:id(.:format) saved_searches#forget

track_search_context POST /catalog/:id/track(.:format) catalog#track

suggest_index GET /suggest(.:format) suggest#index {:format=>“json”}

Blacklight runs on Ruby On Rails as an interface to Apache Solr engine

answered 1 of 4 questions with:

Here is the output

So it appears that the error message

    No route matches [GET] "/catalog"

is correct :grinning: Did you enter that in the address bar or did going to
literally "http:/localhost:3000/" generate that error?

When I input localhost:3000 here is what I get

NameError in CatalogController#index

undefined local variable or method `search_state’ for #CatalogController:0x4182c1c Did you mean? search_results

Extracted source (around line #51):

49
50
51
52
53
54
end

elsif start_new_search_session?

find_or_initialize_search_session_from_params search_state.to_h

elsif search_session['id']

begin

searches_from_history.find(search_session['id'])

`Rails.root: /home/*/railsfiles/search_app`

[Application Trace](http://127.0.0.1:3000/#) | [Framework Trace](http://127.0.0.1:3000/#) | [Full Trace](http://127.0.0.1:3000/#)

blacklight (6.14.1) app/controllers/concerns/blacklight/search_context.rb:51:in find_search_session'](http://127.0.0.1:3000/#) [blacklight (6.14.1) app/controllers/concerns/blacklight/search_context.rb:30:in current_search_session’
blacklight (6.14.1) app/controllers/concerns/blacklight/search_context.rb:35:in set_current_search_session'](http://127.0.0.1:3000/#) [activesupport (5.2.0.rc1) lib/active_support/callbacks.rb:426:in block in make_lambda’
activesupport (5.2.0.rc1) lib/active_support/callbacks.rb:179:in block (2 levels) in halting_and_conditional'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/abstract_controller/callbacks.rb:34:in block (2 levels) in module:Callbacks
activesupport (5.2.0.rc1) lib/active_support/callbacks.rb:180:in block in halting_and_conditional'](http://127.0.0.1:3000/#) [activesupport (5.2.0.rc1) lib/active_support/callbacks.rb:513:in block in invoke_before’
activesupport (5.2.0.rc1) lib/active_support/callbacks.rb:513:in each'](http://127.0.0.1:3000/#) [activesupport (5.2.0.rc1) lib/active_support/callbacks.rb:513:in invoke_before’
activesupport (5.2.0.rc1) lib/active_support/callbacks.rb:131:in run_callbacks'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/abstract_controller/callbacks.rb:41:in process_action’
actionpack (5.2.0.rc1) lib/action_controller/metal/rescue.rb:22:in process_action'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_controller/metal/instrumentation.rb:34:in block in process_action’
activesupport (5.2.0.rc1) lib/active_support/notifications.rb:168:in block in instrument'](http://127.0.0.1:3000/#) [activesupport (5.2.0.rc1) lib/active_support/notifications/instrumenter.rb:23:in instrument’
activesupport (5.2.0.rc1) lib/active_support/notifications.rb:168:in instrument'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_controller/metal/instrumentation.rb:32:in process_action’
actionpack (5.2.0.rc1) lib/action_controller/metal/params_wrapper.rb:256:in process_action'](http://127.0.0.1:3000/#) [activerecord (5.2.0.rc1) lib/active_record/railties/controller_runtime.rb:24:in process_action’
actionpack (5.2.0.rc1) lib/abstract_controller/base.rb:134:in process'](http://127.0.0.1:3000/#) [actionview (5.2.0.rc1) lib/action_view/rendering.rb:32:in process’
actionpack (5.2.0.rc1) lib/action_controller/metal.rb:191:in dispatch'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_controller/metal.rb:252:in dispatch’
actionpack (5.2.0.rc1) lib/action_dispatch/routing/route_set.rb:52:in dispatch'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_dispatch/routing/route_set.rb:34:in serve’
actionpack (5.2.0.rc1) lib/action_dispatch/journey/router.rb:52:in block in serve'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_dispatch/journey/router.rb:35:in each’
actionpack (5.2.0.rc1) lib/action_dispatch/journey/router.rb:35:in serve'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_dispatch/routing/route_set.rb:840:in call’
warden (1.2.7) lib/warden/manager.rb:36:in block in call'](http://127.0.0.1:3000/#) [warden (1.2.7) lib/warden/manager.rb:35:in catch’
warden (1.2.7) lib/warden/manager.rb:35:in call'](http://127.0.0.1:3000/#) [rack (2.0.4) lib/rack/tempfile_reaper.rb:15:in call’
rack (2.0.4) lib/rack/etag.rb:25:in call'](http://127.0.0.1:3000/#) [rack (2.0.4) lib/rack/conditional_get.rb:25:in call’
rack (2.0.4) lib/rack/head.rb:12:in call'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_dispatch/http/content_security_policy.rb:18:in call’
rack (2.0.4) lib/rack/session/abstract/id.rb:232:in context'](http://127.0.0.1:3000/#) [rack (2.0.4) lib/rack/session/abstract/id.rb:226:in call’
actionpack (5.2.0.rc1) lib/action_dispatch/middleware/cookies.rb:663:in call'](http://127.0.0.1:3000/#) [activerecord (5.2.0.rc1) lib/active_record/migration.rb:558:in call’
actionpack (5.2.0.rc1) lib/action_dispatch/middleware/callbacks.rb:28:in block in call'](http://127.0.0.1:3000/#) [activesupport (5.2.0.rc1) lib/active_support/callbacks.rb:98:in run_callbacks’
actionpack (5.2.0.rc1) lib/action_dispatch/middleware/callbacks.rb:26:in call'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_dispatch/middleware/executor.rb:14:in call’
actionpack (5.2.0.rc1) lib/action_dispatch/middleware/debug_exceptions.rb:61:in call'](http://127.0.0.1:3000/#) [web-console (3.5.1) lib/web_console/middleware.rb:135:in call_app’
web-console (3.5.1) lib/web_console/middleware.rb:28:in block in call'](http://127.0.0.1:3000/#) [web-console (3.5.1) lib/web_console/middleware.rb:18:in catch’
web-console (3.5.1) lib/web_console/middleware.rb:18:in call'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:33:in call’
railties (5.2.0.rc1) lib/rails/rack/logger.rb:38:in call_app'](http://127.0.0.1:3000/#) [railties (5.2.0.rc1) lib/rails/rack/logger.rb:26:in block in call’
activesupport (5.2.0.rc1) lib/active_support/tagged_logging.rb:71:in block in tagged'](http://127.0.0.1:3000/#) [activesupport (5.2.0.rc1) lib/active_support/tagged_logging.rb:28:in tagged’
activesupport (5.2.0.rc1) lib/active_support/tagged_logging.rb:71:in tagged'](http://127.0.0.1:3000/#) [railties (5.2.0.rc1) lib/rails/rack/logger.rb:26:in call’
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in call'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:81:in call’
actionpack (5.2.0.rc1) lib/action_dispatch/middleware/request_id.rb:27:in call'](http://127.0.0.1:3000/#) [rack (2.0.4) lib/rack/method_override.rb:22:in call’
rack (2.0.4) lib/rack/runtime.rb:22:in call'](http://127.0.0.1:3000/#) [activesupport (5.2.0.rc1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call’
actionpack (5.2.0.rc1) lib/action_dispatch/middleware/executor.rb:14:in call'](http://127.0.0.1:3000/#) [actionpack (5.2.0.rc1) lib/action_dispatch/middleware/static.rb:127:in call’
rack (2.0.4) lib/rack/sendfile.rb:111:in call'](http://127.0.0.1:3000/#) [railties (5.2.0.rc1) lib/rails/engine.rb:524:in call’
puma (3.11.2) lib/puma/configuration.rb:225:in call'](http://127.0.0.1:3000/#) [puma (3.11.2) lib/puma/server.rb:624:in handle_request’
puma (3.11.2) lib/puma/server.rb:438:in process_client'](http://127.0.0.1:3000/#) [puma (3.11.2) lib/puma/server.rb:302:in block in run’
puma (3.11.2) lib/puma/thread_pool.rb:120:in `block in spawn_thread’


## Request
**Parameters**:

None

When I enter localhost:3000/catalog here what I still get

# Routing Error

No route matches [GET] “/catalog”

Rails.root: /home/dane5890/railsfiles/search_app

Application Trace | Framework Trace | Full Trace


Routes

Routes match in priority from top to bottom

Helper
HTTP Verb
Path
Controller#Action
Path / Url
blacklight_path
/
Blacklight::Engine

root_path
GET
/
catalog#index

new_user_session_path
GET
/users/sign_in(.:format)
devise/sessions#new

user_session_path
POST
/users/sign_in(.:format)
devise/sessions#create

destroy_user_session_path
GET
/users/sign_out(.:format)
devise/sessions#destroy

new_user_password_path
GET
/users/password/new(.:format)
devise/passwords#new

edit_user_password_path
GET
/users/password/edit(.:format)
devise/passwords#edit

user_password_path
PATCH
/users/password(.:format)
devise/passwords#update

PUT
/users/password(.:format)
devise/passwords#update

POST
/users/password(.:format)
devise/passwords#create

cancel_user_registration_path
GET
/users/cancel(.:format)
devise/registrations#cancel

new_user_registration_path
GET
/users/sign_up(.:format)
devise/registrations#new

edit_user_registration_path
GET
/users/edit(.:format)
devise/registrations#edit

user_registration_path
PATCH
/users(.:format)
devise/registrations#update

PUT
/users(.:format)
devise/registrations#update

DELETE
/users(.:format)
devise/registrations#destroy

POST
/users(.:format)
devise/registrations#create

email_solr_document_path
GET>POST
/catalog/:id/email(.:format)
catalog#email

sms_solr_document_path
GET>POST
/catalog/:id/sms(.:format)
catalog#sms

citation_solr_document_path
GET
/catalog/:id/citation(.:format)
catalog#citation

email_solr_documents_path
GET>POST
/catalog/email(.:format)
catalog#email

sms_solr_documents_path
GET>POST
/catalog/sms(.:format)
catalog#sms

citation_solr_documents_path
GET
/catalog/citation(.:format)
catalog#citation

solr_document_path
GET
/catalog/:id(.:format)
catalog#show

catalog_static_pages_path
GET
/static_pages/catalog(.:format)
static_pages#catalog

new_static_pages_path
GET
/static_pages/new(.:format)
static_pages#new

edit_static_pages_path
GET
/static_pages/edit(.:format)
static_pages#edit

static_pages_path
GET
/static_pages(.:format)
static_pages#show

PATCH
/static_pages(.:format)
static_pages#update

PUT
/static_pages(.:format)
static_pages#update

DELETE
/static_pages(.:format)
static_pages#destroy

POST
/static_pages(.:format)
static_pages#create

email_bookmark_path
GET>POST
/bookmarks/:id/email(.:format)
bookmarks#email

sms_bookmark_path
GET>POST
/bookmarks/:id/sms(.:format)
bookmarks#sms

citation_bookmark_path
GET
/bookmarks/:id/citation(.:format)
bookmarks#citation

email_bookmarks_path
GET>POST
/bookmarks/email(.:format)
bookmarks#email

sms_bookmarks_path
GET>POST
/bookmarks/sms(.:format)
bookmarks#sms

citation_bookmarks_path
GET
/bookmarks/citation(.:format)
bookmarks#citation

clear_bookmarks_path
DELETE
/bookmarks/clear(.:format)
bookmarks#clear

bookmarks_path
GET
/bookmarks(.:format)
bookmarks#index

POST
/bookmarks(.:format)
bookmarks#create

new_bookmark_path
GET
/bookmarks/new(.:format)
bookmarks#new

edit_bookmark_path
GET
/bookmarks/:id/edit(.:format)
bookmarks#edit

bookmark_path
GET
/bookmarks/:id(.:format)
bookmarks#show

PATCH
/bookmarks/:id(.:format)
bookmarks#update

PUT
/bookmarks/:id(.:format)
bookmarks#update

DELETE
/bookmarks/:id(.:format)
bookmarks#destroy

rails_service_blob_path
GET
/rails/active_storage/blobs/:signed_id/*filename(.:format)
active_storage/blobs#show

rails_blob_variation_path
GET
/rails/active_storage/variants/:signed_blob_id/:variation_key/*filename(.:format)
active_storage/variants#show

rails_blob_preview_path
GET
/rails/active_storage/previews/:signed_blob_id/:variation_key/*filename(.:format)
active_storage/previews#show

rails_disk_service_path
GET
/rails/active_storage/disk/:encoded_key/*filename(.:format)
active_storage/disk#show

update_rails_disk_service_path
PUT
/rails/active_storage/disk/:encoded_token(.:format)
active_storage/disk#update

rails_direct_uploads_path
POST
/rails/active_storage/direct_uploads(.:format)
active_storage/direct_uploads#create

Routes for Blacklight::Engine
search_history_path
GET
/search_history(.:format)
search_history#index

clear_search_history_path
DELETE
/search_history/clear(.:format)
search_history#clear

clear_saved_searches_path
DELETE
/saved_searches/clear(.:format)
saved_searches#clear

saved_searches_path
GET
/saved_searches(.:format)
saved_searches#index

save_search_path
PUT
/saved_searches/save/:id(.:format)
saved_searches#save

forget_search_path
DELETE
/saved_searches/forget/:id(.:format)
saved_searches#forget

POST
/saved_searches/forget/:id(.:format)
saved_searches#forget

track_search_context_path
POST
/catalog/:id/track(.:format)
catalog#track

suggest_index_path
GET
/suggest(.:format)
suggest#index {:format=>“json”}

Request

Parameters:

None

When I input localhost:3000 here is what I get

NameError in CatalogController#index

undefined local variable or method `search_state' for
#<CatalogController:0x4182c1c>

OK, so that's a totally different thing. Your request is being sent to
the right controller, but "search_state" isn't set, so... you'll have to
figure out where that's intended to come from.

      find_or_initialize_search_session_from_params search_state.to_h

The "_from_params" is probably a clue there...

When I enter localhost:3000/catalog here what I still get

No route matches [GET] "/catalog"

Of course -- why are you even trying that when `rake routes` has
shown the route doesn't exist? If you want it to exist, you have to
create it, but it doesn't seem to be a part of this search thing.

I’ve been trying to create it, and nothing seems to work. So my question is, how do you create it. I’ve never worked with Ruby On Rails

I've been trying to create it, and nothing seems to work.

What is "it"? (Top-posting isn't helping here.)

I've never worked with Ruby On Rails

You might want to spend a little time learning on a more vanilla
Rails app in that case.

In that case I suggest you start by working right through a good tutorial
such as railstutorial.org, which is free to use online. That will show you
the basics of Rails

Colin