I changed some things in my files and when a user is being created instead of going to user/1 it is going to user.1. Any idea why this is happening? Below is print of log extract. Thanks,
Started GET "/user.113" for 95.45.98.59 at 2016-04-18 23:39:53 +0000
ActionController::RoutingError (uninitialized constant UserController): activesupport (4.2.2) lib/active_support/inflector/methods.rb:261:in const_get'
activesupport (4.2.2) lib/active_support/inflector/methods.rb:261:inblock in constantize' activesupport (4.2.2) lib/active_support/inflector/methods.rb:259:in each'
activesupport (4.2.2) lib/active_support/inflector/methods.rb:259:ininject' activesupport (4.2.2)
If you're using a route helper method, and you want to route to the url for a specific resource, make sure you call resource_path(resource)
and not resources_path(resource)
. Note the singular/plural distinction in the route method.
If I understand your question correctly, your controller should look something like this;
class UsersController < ApplicationConroller
# ...
def create
# Create the user...
if @user.valid?
redirect_to user_path(@user) # redirects to `show` action
else
render :new # There are errors, so render the form with errors
end
end
# ...
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.