i have added devise in gemfile , did bundle install..now how can give authentication sage created?
this controller sages.rb
class sagescontroller < applicationcontroller def home end def end def new @sage = sage.new end def create @sage= sage.new(sage_params) if @sage.save flash[:success] = 'thanks joining' redirect_to '/thanks' else flash[:notice] = 'please fill 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
this new.html.erb in sage created
<div class="contact" style="padding: 50px; color: orange "> <%= form_for @sage |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>
this routes.rb
'/thanks'=> 'users#thanks' '/thankss'=>'users#thankss' '/thanksss'=>'users#thanksss' resources :sages,only: [:new,:create,:edit, :update, :delete, :destroy] '/sages/edit/:id'=>'sages#edit' 'sages/home'=>'sages#home' 'sages/about'=>'sages#about' 'sages/resources'=>'sages#resources' 'sages/delete/:id'=> 'sages#delete' delete 'sages/delete/:id'=> 'sages#destroy'
Comments
Post a Comment