I have been following this to set up state/country drop downs for my rails application but notice that I'm getting the following error:
Started GET "/jobs/subregion_options?parent_region=BR" for 127.0.0.1 at 2013-12-13 21:01:09 +0000
Processing by JobsController#show as HTML
Parameters: {"parent_region"=>"BR", "id"=>"subregion_options"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Job Load (0.2ms) SELECT "jobs".* FROM "jobs" WHERE "jobs"."id" = ? LIMIT 1 [["id", "subregion_options"]]
Completed 404 Not Found in 4ms
ActiveRecord::RecordNotFound (Couldn't find Job with id=subregion_options):
app/controllers/jobs_controller.rb:75:in `set_job'
I cannot understand why this is doing this when my set_job filter is only as shown below:
before_action :set_job, only: [:show, :edit, :update, :destroy]
Here is the link I'm following with he use of a partial and routes:
https://github.com/jim/carmen-demo-app
Routes
jobs GET /jobs(.:format) jobs#index
POST /jobs(.:format) jobs#create
new_job GET /jobs/new(.:format) jobs#new
edit_job GET /jobs/:id/edit(.:format) jobs#edit
job GET /jobs/:id(.:format) jobs#show
PATCH /jobs/:id(.:format) jobs#update
PUT /jobs/:id(.:format) jobs#update
DELETE /jobs/:id(.:format) jobs#destroy
root GET / pages#index
jobs_subregion_options GET /jobs/subregion_options(.:format) jobs#subregion_options
Appreciate the help.
You are missing the route for subregion_options
, in your routes.rb
you will have to add something like
resources :jobs do
collection do
get :subregion_options
end
end
Or, as suggested in the readme of the demo-app:
get '/jobs/subregion_options' => 'jobs#subregion_options'
Now it hits the show
action and tries to look for a job with id = subregion_options
, which I am pretty sure is not what you want :)