Rails object will not be created
Ruby 1.8.7, Rails 2.3.11
Main question: what could cause Rails to send me the index page for an object type after trying to create a new object of that type? No errors produced, no success message, no new entries in the database
I used ruby script/generate scaffold poster owner_id:integer event_id:integer
to create a standard scaffold, then ran rake db:migrate
. Without changing any files, I tried to create a new poster object, and it sent me to /posters rather than /posters/show/1, as it's supposed to do.
Other information which may be of help:
There are other object types already in place on the server. This problem originally cropped up when I was trying to have the poster belong_to :owner and belong_to :event.
If the information was getting to the model to be validated, it would return an error blank required entries. If I enter the data manually into the MySQL database, it shows up in the index page, and can be edited (and saved) without issue. Because of that, I think that the issue is either in the controller file or the database itself, but nothing raised a red flag when I looked through.
I have minimal (4 weeks of a class) experience with Rails, and have been stuck on this for three days now.
routes.rb: (commented lines st开发者_StackOverflow社区ripped)
ActionController::Routing::Routes.draw do |map|
map.resources :posters
map.resources :place_informations
map.resources :building_polygon_coordinates
map.resources :alternate_names
map.resources :events
map.resources :hours_listings
map.resources :locations
map.connect 'json/buildings', :controller => 'json', :action => 'buildings'
map.resources :users
map.resources :buildings
map.root :controller => "home"
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
Applicable part of development.log: (the very end; just the attempt to create a new poster; SQL calls stripped out)
Processing PostersController#index (for <my IP address> at 2011-05-26 20:32:44) [GET]
~~ SQL stuff, call timings ~~~
Rendering template within layouts/posters
Rendering posters/index
~~ SQL stuff, call timings ~~~
Processing PostersController#new (for <my IP address> at 2011-05-26 20:32:48) [GET]
~~ SQL stuff, call timings ~~~
Rendering template within layouts/posters
Rendering posters/new
~~ SQL stuff, call timings ~~~
Processing PostersController#index (for <my IP address> at 2011-05-26 20:32:56) [GET]
~~ SQL stuff, call timings ~~~
Rendering template within layouts/posters
Rendering posters/index
~~ SQL stuff, call timings ~~~
It is "get index, get new, get index"
It should be* "get index, get new, post create, get show, get index"I got it fixed.
The DirectorySlash toggle in Apache had to be set to "Off". I'm not sure why that affected it in the way that it did, but the issue was resolved after adding the line DirectorySlash Off
to ".htaccess".
精彩评论