我刚刚创立了一条新的铁路线3.1.1,而我的应用布局并不在浏览器中提供。 唯一的事情是我的看法中提出的法典(例如意见/公共/家庭.html.erb)。
它只提供管道和管道;%=产量; 例如,当地东道方:3000/public/home仅显示:
<h1>Homepage</h1>
<h2>Here we go.</h2>
<a href="/#">Visit the login page</a>
这里指的是我/layouts/application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>My App</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<ul class="user_nav">
<% if current_user %>
<li>
Logged in as <%= current_user.email %>.
</li>
<li>
<%= link_to "Log out", logout_path %>
</li>
<% else %>
<li>
<%= link_to "Sign up", signup_path %>
</li>
<li>
<%= link_to "Log in", login_path %>
</li>
<% end %>
</ul>
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => "flash#{name}" %>
<% end %>
<%= yield %>
<h1>test!</h1>
</body>
</html>
这里也是我的道路:
root :to => "public#home"
match "/secret" => "public#secret"
get "logout" => "sessions#destroy", :as => "logout"
get "login" => "sessions#new", :as => "login"
get "signup" => "users#new", :as => "signup"
resources :users
resources :sessions
此处是应用中的内容:
class ApplicationController < ActionController::Base
protect_from_forgery
end
这里指公共控制者:
class PublicController < ActionController::Base
protect_from_forgery
def home
end
def secret
end
end
这里指的是会议:
class SessionsController < ApplicationController
def new
end
def create
user = login(params[:email], params[:password], params[:remember_me])
if user
redirect_back_or_to root_path, :notice => "Logged in!"
else
flash.now.alert = "Email or password was invalid"
render :new
end
end
def destroy
logout
redirect_to root_path, :notice => "Logged out"
end
end
这里指用户中的控制器:
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to root_path, :notice => "Signed up!"
else
render :new
end
end
end