You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: features_controller.rb
    path of file: ./repos/plots2/app/controllers
    
    the code of the file until where you have to start completion: class FeaturesController < ApplicationController
  before_action :require_user, except: [:embed]

  def index
    @title = "Features"
    @features = Node.where(type: 'feature')
    @sorted_features = Node.sort_features(@features, params[:sort]).paginate(page: params[:page])
  end

  def embed
    @node = Node.find_by(title: params[:id])
    render layout: false
  end

  def new
    @node = Node.new
    @revision = Revision.new
    unless current_user.admin?
      flash[:warning] = 'Only admins may edit features.'
      redirect_to '/features'
    end
  end

  def edit
    if !current_user.admin?
      flash[:warning] = 'Only admins may edit features.'
      redirect_to '/features'
    else
      @node = Node.find params[:id]
    end
  end

    
  def create
    if !current_user.admin?
      flash[:warning] = 'Only admins may edit features.'
      redirect_to "/features?_=#{Time.now.to_i}"
    else
      @node = Node.new(uid:   current_user.id,
                       title: params[:title],
                       type:  'feature')
      if @node.valid?
        saved = true
        @revision = false
        ActiveRecord::Base.transaction do
          @node.save!
          @revision = @node.new_revision(uid:   current_user.id,
                                         title: params[:title],
                                         body:  params[:body])
          if @revision.valid?
            @revision.save!
            @node.vid = @revision.vid
            @node.save!
          else
            saved = false
            @node.destroy
          end
        end