我正在使用Sorcery Gem来执行登录操作。在某一点上,我只是想打一个方法,并返回1或0,如果用户电子邮件&密码存在于数据库中。我可以用这段代码做到这一点,但Rails也返回我不想要的application.html.erb文件。我需要的只是0或1出现。没有其他的。想知道如何才能禁用application.html.erb模板只有这一个方法。我尝试过:Rails:我想在浏览器中显示一个值,但不想显示application.htm.erb
render :layout => false
但这也阻止了我的@状态值出现在我的一行视图文件中。
def index
if @user = login(params[:email], params[:password])
@status = '1'
else
@status = '0'
end
end
我的index.html.erb文件仅仅是一个行: <%= @status%>
感谢
'index layout'方法末尾的'render layout:false'应该按照你想要的来做。 – bdares 2013-03-15 03:44:07
这个伎俩。 – 2013-03-15 03:55:23