Rubyonrails.org's Getting Started tutorial: small code snippet not working in RoR 2.3.13
Just to clarify, I meant rails v3.2.13
The page: http://guides.rubyonrails.org/v3.2.13/getting_started.html
In the 10 Security section, the http_basic_authenticate_with does not ask for authentication for new posts. It does work when you are removing comments, but that is a separate and slightly different line of code. I'm going to move on, but any help here would be appreciated.
.
comments controller (authenticate working)
class CommentsController < ApplicationController
http_basic_authenticate_with :name => 'dhh', :password => 'secret', :only => :destroy
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create(params[:comment])
redirect_to post_path(@post)
end
def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
end
end
posts controller(authenticate not working)
class PostsController < ApplicationController
http_basic_authenticate_with :name => "dhh", :password => "secret", :except => [:index, :show]
# GET /posts
# GET /posts.json
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @posts }
end
end
# GET /posts/1
# GET /posts/1.json
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @post }
end
end
# Snippet for brevity
Posted Jul 16, 2013, 2:36 AM UTC · edited
215