我已经在我的Gemfile中添加了设备并进行了捆绑安装..现在我该如何为创建的sage提供身份验证?
这是我的控制器sages.rb
class SagesController < ApplicationController
def home
end
def about
end
def new
@sage = Sage.new
end
def create
@sage= Sage.new(sage_params)
if @sage.save
flash[:success] = 'Thanks for Joining'
redirect_to '/thanks'
else
flash[:notice] = 'Please fill the form Correctly'
render 'new'
end
end
def edit
@sage=Sage.find(params[:id])
end
def update
@sage = Sage.find(params[:sage])
if @sage.update_attributes(sage_params)
redirect_to '/thankss'
else
render 'new'
end
end
def resources
end
private
def sage_params
params.require(:sage).permit(:Name, :Email, :Address, :Number)
end
end
这是我的new.html.erb,其中创建了一个sage
<div class="contact" style="padding: 50px; color: orange ">
<%= form_for @sage do |f| %>
<div class="form-group" >
<h3><%= f.label :Name%></h3>
<%= f.text_field :Name %>
<br/>
</div>
<div class="form-group" >
<h3><%= f.label :Email%></h3>
<%= f.email_field :Email %>
</div>
<div class="form-group" >
<h3><%= f.label :Address%></h3>
<%= f.text_field :Address %>
<br/>
</div>
<div class="form-group" >
<h3> <%= f.label :Number%></h3>
<%= f.number_field :Number %>
<br/>
</div>
<br/>
<br/>
<div class="submit" >
<h2><%= f.submit 'SUBMIT'%></h2>
</div>
<% end %>
</div>
这是我的routes.rb
get '/thanks'=> 'users#thanks'
get '/thankss'=>'users#thankss'
get '/thanksss'=>'users#thanksss'
resources :sages,only: [:new,:create,:edit, :update, :delete, :destroy]
get '/sages/edit/:id'=>'sages#edit'
get 'sages/home'=>'sages#home'
get 'sages/about'=>'sages#about'
get 'sages/resources'=>'sages#resources'
get 'sages/delete/:id'=> 'sages#delete'
delete 'sages/delete/:id'=> 'sages#destroy'