1 2 3 | <% content_for :ArticleNumber do %> <%= @articles.length %> <% end %> |
1 2 3 4 5 6 | <head> <title>Demoblog has <%= yield :ArticleNumber %> articles. </title> <%= stylesheet_link_tag :all %> <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %> </head> |
1 2 3 4 5 6 7 8 9 10 11 12 | class CommentsController < ApplicationController def create @last_name = cookies[:name] @name = params[:comment][:user] unless @name == @last_name cookies[:last_name] = @last_name cookies[:name] = @name else cookies[:last_name] = nil end end end |
1 2 3 4 5 6 | def show @article = Article.find(params[:id]) @last_name = cookies[:last_name] unless @last_name == nil @name = cookies[:name] end |
1 2 3 4 5 6 7 8 | @names = session[:name] if @names @names = [] end if @name @names << @name end session[:names] = @names |
1 2 3 4 5 6 7 8 | <% if @names %> <p>The names you have used:</p> <ul> <% @names.each do |name| %> <li><%=h name %></li> <% end %> </ul> <% end %> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |