|
I’m at the point in this exercise where I can create a user (name, email, password, password-conf), but when I submit that form, I get the following error:
ActionController::MethodNotAllowed Only get, head, post, put, and delete requests are allowed. RAILS_Root: /usr/local/exercisr Headers: (“cookie”=>[],
“Cache-Control”=>”no-cache”,
“Allow”=>”GET,
HEAD,
POST,
PUT,
DELETE”}
As far as I can tell, there is a problem with the welcome path, but I can’t figure it out. Any help would be appreciated.
Here are the contents of my files: .../config/routes.rb: ActionController::Routing::Routes.draw do |map|
map.resources :exercisers
map.home ’’, :controller => ‘sessions’, :action => ‘new’
map.resources :users, :sessions
map.welcome ’/welcome’, :controller => ‘sessions’, :action => ‘welcome’
map.signup ’/signup’, :controller => ‘users’, :action => ‘new’
map.login ’/login’, :controller => ‘sessions’, :action => ‘create’
map.logout ’/logout’, :controller => ‘sessions’, :action => ‘destroy’
map.connect ’:controller/:action/:id’
map.connect ’:controller/:action/:id.:format’ end
.../app/controllers/application.rb: class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
before_filter :login_from_cookie
session :session_key => ‘_exercisr_session_id’
include AuthenticatedSystem
- See ActionController::RequestForgeryProtection for details
- Uncomment the :secret if you’re not using the cookie session store
protect_from_forgery # :secret => ‘c3f7d2ecee34d3b3ff8e9117984956ee’
end
.../app/controllers/sessions_controller.rb:
- This controller handles the login/logout function of the site.
class SessionsController < ApplicationController
# render new.rhtml
def new
end
def create
self.current_user = User.authenticate(params[:login], params[:password])
if logged_in?
if params[:remember_me] == "1"
current_user.remember_me
cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expire s_at }
end
redirect_back_or_default(welcome_path)
flash[:notice] = "Logged in successfully"
else
render :action => 'new'
end
end
def welcome
end
def destroy
self.current_user.forget_me if logged_in?
cookies.delete :auth_token
reset_session
flash[:notice] = "You have been logged out."
redirect_back_or_default(login_path)
end end
.../app/controllers/users_controller.rb class UsersController < ApplicationController
# render new.rhtml
def new
end
def create
@user = User.new(params[:user])
@user.save!
self.current_user = @user
redirect_back_or_default(welcome_path)
flash[:notice] = "Thanks for signing up!"
Rescue ActiveRecord:RecordInvalid
render :action => 'new'
end
end
end
.../app/views/sessions/new.html.erb: <% form_tag sessions_path do ->
<label for="login">Login</label>
< = text_field_tag ‘login’ %>
<label for="password">Password</label>
<%= password_field_tag ‘password’ %>
<!- Uncomment this if you want this functionality
<label for="remember_me">Remember me:</label> <%= check_box_tag ‘remember_me’ %>
->
<= submit_tag ‘Log in’ %> < end -%>
.../app/views/sessions/welcome.rhtml:
Welcome to Exercisr
A RESTful place to keep track of your workouts
|