FrontPage  Index  Search  Changes  Login

rails

INDEX

コントローラ名の取得

contoller_name

レイアウト

  • application.erb
<html>
<head>
  <title>books</title>
</head>
<body>
<%= yield %>
</body>
</html>

@content_for_layout は非推奨

Even the old @content_for_layout in the layout is deprecated in favor of just using yield in its place.
Use params, not @params

フィルタ

class ApplicationController < ActionController::Base
  protect_from_forgery
  before_filter :authenticate

  private
  def authenticate
    redirect_to url_for :controller => "welcome" unless session[:login]
  end
end

リダイレクト

別のコントローラへ

redirect_to :controller => "welcome"

url_for を使う

redirect_to url_for :controller => "welcome"

フォーム

<% form_tag('/welcome/login') do -%>
  <%= text_field(:login, :name, :size => 20) %><br>
  <%= password_field(:login, :password, :size => 20) %><br>
  <%= submit_tag :search %>
<% end -%>
Last modified:2010/04/25 21:36:55
Keyword(s):
References:[FrontPage]