Tôi đã đoạn mã sau vào bộ điều khiển của tôiTại sao: Thông báo không hiển thị sau khi chuyển hướng trong Rails 3
def create
@tv_show = TvShow.new(params[:tv_show])
respond_to do |format|
if @tv_show.save
format.html { redirect_to(tv_shows_path, :notice => 'Tv show was successfully created.') }
format.xml { render :xml => @tv_show, :status => :created, :location => @tv_show }
else
format.html { render :action => "new" }
format.xml { render :xml => @tv_show.errors, :status => :unprocessable_entity }
end
end
end
và sau đây trong tv_shows tôi/index.html.erb
<div id="notice"><%= notice %></div>
nhưng khi Tôi tạo một mục mới thông báo thông báo không xuất hiện sau khi chuyển hướng đến tv_shows_path. Có ai biết tại sao không?
Tôi tự hỏi nếu bạn có thể cụ thể. Tôi gặp vấn đề tương tự, và câu trả lời này không giúp được gì. Bộ điều khiển của tôi có 'before_filter: authenticate_user!'. Là sai đó? –
Xin lỗi nhưng tôi không biết vấn đề này là gì một năm trước. Tại thời điểm này tôi sử dụng has_secure_password kể từ Rails 3.1 và điều này làm việc thực sự tuyệt vời cho tôi. http://railscasts.com/episodes/270-authentication-in-rails-3-1 – maveonair