Question I have a button that I want to be able to let the user see a specific entry in another view. The problem I am having is figuring out how to route my button because when I click on it I get this as the button path
(Started GET "/entry/emp_accum.11400)
which then gives me this error
(Couldn't find Entry with 'id'=) I would like
I want it look like this thought and for some reason I can't seem to get it to work..
(Started GET "/entry/11400/emp_accum)
Any help would be greatly appreciated.
System = Ruby on rails 4.2.4 and ruby 1.9.3
Views = HAML
Here is my controller
class EntryController < ApplicationController
def emp_accum
@entry = Entry.find(params[:id])
render :emp_accum
end
Here is my view with the button
%table.table.table-bordered.trace-table
%thead
%tr.trace-table
%th.ts{:style => 'border: solid black;'} Show entry button
%tr.trace-table
-@entry.each do |e|
%td.trace-table{:style => 'width:5%;' 'border: solid black;'}= link_to "+", emp_accum_entry_index_path(e.id), :class => "alt"
And here are my routes
resources :entry do
collection { post :import }
collection do
get 'my_group'
put 'my_group'
get 'emp_accum'
put 'emp_accum'
post 'emp_accum'
end
member do
put 'man_push'
get 'emp_accum'
put 'emp_accum'
post 'emp_accum'
end
end
# I tried this as well
match "/entry/:id/emp_accum/", :controller => "entry", :action => "emp_accum", via: [:get, :post]
match "/entry/emp_accum/.:id/", :controller => "entry", :action => "emp_accum", via: [:get, :post]
And finally here are my raked routes
Prefix Verb URI Pattern Controller#Action
import_entry_index POST /entry/import(.:format) entry#import
my_group_entry_index GET /entry/my_group(.:format) entry#my_group
PUT /entry/my_group(.:format) entry#my_group
emp_accum_entry_index GET /entry/emp_accum(.:format) entry#emp_accum
PUT /entry/emp_accum(.:format) entry#emp_accum
POST /entry/emp_accum(.:format) entry#emp_accum
lock_out_entry POST /entry/:id/lock_out(.:format) entry#lock_out
PUT /entry/:id/lock_out(.:format) entry#lock_out
unlock_out_entry POST /entry/:id/unlock_out(.:format) entry#unlock_out
PUT /entry/:id/unlock_out(.:format) entry#unlock_out
man_push_entry POST /entry/:id/man_push(.:format) entry#man_push
PUT /entry/:id/man_push(.:format) entry#man_push
emp_accum_entry GET /entry/:id/emp_accum(.:format) entry#emp_accum
PUT /entry/:id/emp_accum(.:format) entry#emp_accum
POST /entry/:id/emp_accum(.:format) entry#emp_accum
entry_index GET /entry(.:format) entry#index
POST /entry(.:format) entry#create
new_entry GET /entry/new(.:format) entry#new
edit_entry GET /entry/:id/edit(.:format) entry#edit
entry GET /entry/:id(.:format) entry#show
PATCH /entry/:id(.:format) entry#update
PUT /entry/:id(.:format) entry#update
DELETE /entry/:id(.:format) entry#destroy
GET|POST /entry(.:format) entry#index
GET|POST /entry/:id/emp_accum(.:format) entry#emp_accum
GET|POST /entry/emp_accum/.:id(.:format) entry#emp_accum
entry_emp_accum GET /entry/emp_accum(.:format) entry#emp_accum
Aucun commentaire:
Enregistrer un commentaire