pokaż config/routes.rb i dodaj logi jakie wypluwa przy wywołaniu akcji
to są logi:
[code]Processing NamesController#index (for 127.0.0.1 at 2010-05-10 11:02:34) [GET]
e[4;36;1mName Load (1.0ms)e[0m e[0;1mSELECT * FROM names e[0m
Rendering template within layouts/names
Rendering names/index
e[4;35;1mName Columns (1.0ms)e[0m e[0m select column_name as name, data_type as sql_type, data_default, nullable,
decode(data_type, ‘NUMBER’, data_precision,
‘FLOAT’, data_precision,
‘VARCHAR2’, data_length,
‘CHAR’, data_length,
null) as limit,
decode(data_type, ‘NUMBER’, data_scale, null) as scale
from all_tab_columns
where owner = ‘SYSTEM’
and table_name = ‘NAMES’
order by column_id
e[0m
Completed in 2300ms (View: 2287, DB: 2) | 200 OK [http://localhost/names/]
Processing NamesController#edit to 0 (for 127.0.0.1 at 2010-05-10 11:02:40) [GET]
Parameters: {“id”=>“68”}
e[4;36;1mName Columns (1.0ms)e[0m e[0;1m select column_name as name, data_type as sql_type, data_default, nullable,
decode(data_type, ‘NUMBER’, data_precision,
‘FLOAT’, data_precision,
‘VARCHAR2’, data_length,
‘CHAR’, data_length,
null) as limit,
decode(data_type, ‘NUMBER’, data_scale, null) as scale
from all_tab_columns
where owner = ‘SYSTEM’
and table_name = ‘NAMES’
order by column_id
e[0m
e[4;35;1mName Load (3.0ms)e[0m e[0mSELECT * FROM names WHERE (names.id = ‘68’) e[0m
ActionView::MissingTemplate (Missing template names/edit.erb in view path app/views):
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in
run’
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in
start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in
start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in each' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in
start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in
start’
Rendering rescues/layout (internal_server_error)
Processing NamesController#edit (for 127.0.0.1 at 2010-05-10 11:02:45) [GET]
Parameters: {“id”=>“68”}
e[4;36;1mName Columns (1.0ms)e[0m e[0;1m select column_name as name, data_type as sql_type, data_default, nullable,
decode(data_type, ‘NUMBER’, data_precision,
‘FLOAT’, data_precision,
‘VARCHAR2’, data_length,
‘CHAR’, data_length,
null) as limit,
decode(data_type, ‘NUMBER’, data_scale, null) as scale
from all_tab_columns
where owner = ‘SYSTEM’
and table_name = ‘NAMES’
order by column_id
e[0m
e[4;35;1mName Load (1.0ms)e[0m e[0mSELECT * FROM names WHERE (names.id = ‘68’) e[0m
Rendering template within layouts/names
Rendering names/edit
Completed in 29ms (View: 11, DB: 2) | 200 OK [http://localhost/names/edit/68]
Processing NamesController#68 (for 127.0.0.1 at 2010-05-10 11:02:47) [POST]
Parameters: {“name”=>{“imie”=>“ds”, “nazwisko”=>“dswwwwwwwwwwwwwwwwwwwww”}, “commit”=>“Save changes”, “authenticity_token”=>“NGDXZvTQOpVR9icX9vfj+aflC2Kq+pdf8riRrc/qpPk=”}
ActionController::UnknownAction (No action responded to 68. Actions: create, destroy, edit, index, new, show, and update):
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in
run’
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in
start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in
start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in each' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in
start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in
start’
Rendering rescues/layout (not_found)[/code]
a przy uruchomieniu routes.rb
routes.rb:1 uninitialized constant ActionController (Name Error)
ActionView::MissingTemplate (Missing template names/edit.erb in view path app/views):
ja byk pisze ze nie masz widoku dla edycji w katalogu app/views/names/
tylko że ja tam mam ten plik…tak samo jak i new.erb, show.erb, index.erb…więc ciągle nie wiadomo o co chodzi.
zmień nazwe na edit.html.erb
to jest plik typu erb i on istnieje bo będąc właśnie na podstronie edit wysypuje się wyżej wspomniany błąd…chyba że czegoś nie rozumiem…
błąd w związku z brakiem widoku edit pojawia się wtedy gdy tak jak wcześniej pisałem przekazywane id ma postać np 66.0 a kiedy poprawiam na 66 to jest ok ale kiedy naciskać button aby zrobić update to pojawia się właśnie takie błąd:
No action responded to 44. Actions: create, destroy, edit, index, new, show, and update
czyli tak jakby w pliku edit
[code]
Editing name
<% form_for :name, @name, :url => { :action => “update” } do |f| %>
<%= f.label :imie, ‘Imie’ %>:
<%= f.text_field :imie %>
<%= f.label :nazwisko, ‘Nazwisko’ %>:
<%= f.text_field :nazwisko %>
<%= submit_tag “Save changes” %>
<% end %>[/code]
źle zczytywało tą linijkę:
<% form_for :name, @name, :url => { :action => "update" } do |f| %>
to znaczy nie widziało akcji “update”, bo kiedy (metodą prób i błędów w to miejsce daje np “aupdate” to po prostu wyświetla się że brak takiego widoku.
a w jakim miejscu w routes.rb masz wpisane map.resources :names ?
powinno być przed :
map.connect ":controller/:action/:id"
Plik wygląda tak więc chyba jest ok:
[code]ActionController::Routing::Routes.draw do |map|
map.resources :names
The priority is based upon order of creation: first created -> highest priority.
Sample of regular route:
map.connect ‘products/:id’, :controller => ‘catalog’, :action => ‘view’
Keep in mind you can assign values other than :controller and :action
Sample of named route:
map.purchase ‘products/:id/purchase’, :controller => ‘catalog’, :action => ‘purchase’
This route can be invoked with purchase_url(:id => product.id)
Sample resource route (maps HTTP verbs to controller actions automatically):
map.resources :products
Sample resource route with options:
map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
Sample resource route with sub-resources:
map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
Sample resource route with more complex sub-resources
map.resources :products do |products|
products.resources :comments
products.resources :sales, :collection => { :recent => :get }
end
Sample resource route within a namespace:
map.namespace :admin do |admin|
# Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
admin.resources :products
end
You can have the root of your site routed with map.root – just remember to delete public/index.html.
map.root :controller => “welcome”
See how all your routes lay out with “rake routes”
Install the default routes as the lowest priority.
Note: These default routes make all actions in every controller accessible via GET requests. You should
consider removing or commenting them out if you’re using named routes and resources.
map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’
end[/code]