我的会话控制器
class SessionsController < ApplicationController
skip_before_filter :is_loggedin?, :only => [:new, :create]
def new
render :action => "new", :layout => false
end
def create
render :update do |page|
if !params[:email].blank? && !params[:password].blank?
if user = User.authenticate(params[:email], params[:password])
if user == "unuser"
page.alert("Your username and/or password was incorrect.")
elsif !user.account_id.blank?
if params[:remember_me]
cookies.permanent[:user_id] = user.id
else
cookies[:user_id]=user.id
end
user.update_attributes(:last_login => Time.now, :is_online => true)
if user.user_type=="mentor"
page.redirect_to home_mentors_path(:account_id =>user.account_id)
else
page.redirect_to home_students_path(:account_id =>user.account_id)
end
else
page.alert("You have not confirmed the activation link yet. Please check your registered email ")
end
else
page << "jQuery('#login_error').html('Invalid user/password');"
end
else
page.alert("You can't leave this empty.")
end
end
My sessions/_form.htm is like this:
<%= form_tag sessions_path, :remote => true, :method =>"post" do %>
<div id="login-modal" class="shadow" style="display: block; z-index: 4000;">
<div class="login_bar_top">
<div class="login_bar_left"></div>
<div class="login_bar_mid">User Login</div>
<div class="login_bar_right"></div>
</div>
我有很多带有代码渲染的控制器:更新,现在需要花费大量时间来审核所有,使用respond_to做。我也尝试过安装prototype-rails gem。没解决。 我面临的错误是:
Started POST "/sessions" for 127.0.0.1 at 2013-12-10 13:59:50 +0530
Processing by SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"42cE1Mx5gXzmZAbSwgSnxbbygYLH4x81lbPjkCDKAOs=", "email"=>"mentor@gmail.com", "password"=>"[FILTERED]"}
Completed 500 Internal Server Error in 2ms
ActionView::MissingTemplate (Missing template sessions/update, application/update with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee, :rjs]}. Searched in:
* "/home/prz/project/techzoorails/techzoo3/app/views"
):
app/controllers/sessions_controller.rb:9:in `create'
以前它工作正常。有没有任何解决方案,保持渲染:更新代码。我使用rails 3.0.9和ruby 1.9.3p392。