Problem With Blacklight Catalog Routes

83 views
Skip to first unread message

Dane Terrell

unread,
Feb 8, 2018, 2:00:41 PM2/8/18
to Ruby on Rails: Talk
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 

Hassan Schroeder

unread,
Feb 8, 2018, 2:45:43 PM2/8/18
to rubyonrails-talk
On Thu, Feb 8, 2018 at 9:53 AM, Dane Terrell <dane...@gmail.com> wrote:
> 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.

Never heard of Blacklight but the first obvious questions are

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

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Dane Terrell

unread,
Feb 8, 2018, 3:02:16 PM2/8/18
to Ruby on Rails: Talk
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

Hassan Schroeder

unread,
Feb 8, 2018, 3:43:48 PM2/8/18
to rubyonrails-talk
On Thu, Feb 8, 2018 at 12:02 PM, Dane Terrell <dane...@gmail.com>
answered 1 of 4 questions with:

> Here is the output

So it appears that the error message

No route matches [GET] "/catalog"

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

Dane Terrell

unread,
Feb 8, 2018, 3:48:50 PM2/8/18
to Ruby on Rails: Talk
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 | Framework Trace | Full Trace
blacklight (6.14.1) app/controllers/concerns/blacklight/search_context.rb:51:in `find_search_session'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.4) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.4) lib/rack/etag.rb:25:in `call'
rack (2.0.4) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.4) lib/rack/head.rb:12:in `call'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
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'
rack (2.0.4) lib/rack/method_override.rb:22:in `call'
rack (2.0.4) lib/rack/runtime.rb:22:in `call'
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'
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'
railties (5.2.0.rc1) lib/rails/engine.rb:524:in `call'
puma (3.11.2) lib/puma/configuration.rb:225:in `call'
puma (3.11.2) lib/puma/server.rb:624:in `handle_request'
puma (3.11.2) lib/puma/server.rb:438:in `process_client'
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

Routes

Routes match in priority from top to bottom

HelperHTTP VerbPathController#Action
Path / Url
blacklight_path/

Blacklight::Engine

root_pathGET/

catalog#index

new_user_session_pathGET/users/sign_in(.:format)

devise/sessions#new

user_session_pathPOST/users/sign_in(.:format)

devise/sessions#create

destroy_user_session_pathGET/users/sign_out(.:format)

devise/sessions#destroy

new_user_password_pathGET/users/password/new(.:format)

devise/passwords#new

edit_user_password_pathGET/users/password/edit(.:format)

devise/passwords#edit

user_password_pathPATCH/users/password(.:format)

devise/passwords#update

PUT/users/password(.:format)

devise/passwords#update

POST/users/password(.:format)

devise/passwords#create

cancel_user_registration_pathGET/users/cancel(.:format)

devise/registrations#cancel

new_user_registration_pathGET/users/sign_up(.:format)

devise/registrations#new

edit_user_registration_pathGET/users/edit(.:format)

devise/registrations#edit

user_registration_pathPATCH/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_pathGET/catalog/citation(.:format)

catalog#citation

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

catalog#show

catalog_static_pages_pathGET/static_pages/catalog(.:format)

static_pages#catalog

new_static_pages_pathGET/static_pages/new(.:format)

static_pages#new

edit_static_pages_pathGET/static_pages/edit(.:format)

static_pages#edit

static_pages_pathGET/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_pathGET/bookmarks/citation(.:format)

bookmarks#citation

clear_bookmarks_pathDELETE/bookmarks/clear(.:format)

bookmarks#clear

bookmarks_pathGET/bookmarks(.:format)

bookmarks#index

POST/bookmarks(.:format)

bookmarks#create

new_bookmark_pathGET/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_pathPOST/rails/active_storage/direct_uploads(.:format)

active_storage/direct_uploads#create

Routes for Blacklight::Engine
search_history_pathGET/search_history(.:format)

search_history#index

clear_search_history_pathDELETE/search_history/clear(.:format)

search_history#clear

clear_saved_searches_pathDELETE/saved_searches/clear(.:format)

saved_searches#clear

saved_searches_pathGET/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

Hassan Schroeder

unread,
Feb 8, 2018, 4:12:23 PM2/8/18
to rubyonrails-talk
On Thu, Feb 8, 2018 at 12:48 PM, Dane Terrell <dane...@gmail.com> wrote:
> 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.

Dane Terrell

unread,
Feb 8, 2018, 4:25:15 PM2/8/18
to Ruby on Rails: Talk
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

Hassan Schroeder

unread,
Feb 9, 2018, 10:51:48 AM2/9/18
to rubyonrails-talk
On Thu, Feb 8, 2018 at 1:25 PM, Dane Terrell <dane...@gmail.com> wrote:
> 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.

Colin Law

unread,
Feb 9, 2018, 11:01:58 AM2/9/18
to Ruby on Rails: Talk
On 8 February 2018 at 21:25, Dane Terrell <dane...@gmail.com> wrote:
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

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
Reply all
Reply to author
Forward
0 new messages