Class: Blog::Gem::AuthorsController
  
  
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #current_author, #login_as_author
  
  
    Instance Method Details
    
      
  
  
    #create  ⇒ Object 
  
  
  
  
    | 
47
48
49
50
51
52
53
54
55
56 | # File 'app/controllers/blog/gem/authors_controller.rb', line 47
def create
  @author = Blog::Gem::Author.new(author_params)
  respond_to do |format|
    if @author.save
      format.html { redirect_to "#{Blog::Gem.path}/authors/me/edit", notice: 'Author was successfully created.' }
    else
      format.html { render :new }
    end
  end
end | 
 
    
      
  
  
    #destroy  ⇒ Object 
  
  
  
  
    | 
68
69
70
71
72
73
74 | # File 'app/controllers/blog/gem/authors_controller.rb', line 68
def destroy
  @author.destroy
  respond_to do |format|
    format.html { redirect_to authors_url, notice: 'Author was successfully destroyed.' }
    format.json { head :no_content }
  end
end | 
 
    
      
  
  
    #edit  ⇒ Object 
  
  
  
  
    | 
44
45 | # File 'app/controllers/blog/gem/authors_controller.rb', line 44
def edit
end | 
 
    
      
  
  
    #index  ⇒ Object 
  
  
  
  
    | 
34
35
36
37 | # File 'app/controllers/blog/gem/authors_controller.rb', line 34
def index
  @authors = Blog::Gem::Author.all
  @page_title = "Listing Authors"
end | 
 
    
      
  
  
    #login  ⇒ Object 
  
  
  
  
    | 
21
22
23
24
25
26 | # File 'app/controllers/blog/gem/authors_controller.rb', line 21
def login
  if session[:author_id].present?
    redirect_to blogs_path
  end
  @page_title = "Author Login"
end | 
 
    
      
  
  
    #login_submit  ⇒ Object 
  
  
  
  
    | 
10
11
12
13
14
15
16
17
18
19 | # File 'app/controllers/blog/gem/authors_controller.rb', line 10
def login_submit
  @page_title = "Author Login"
  if Blog::Gem::Author.find_by(public_email: params[:email]).try(:authenticate, params[:password])
    session[:author_id] = Blog::Gem::Author.find_by(public_email: params[:email]).id
    redirect_to blogs_path, notice: "You are Logged in!"
  else
    flash[:error] = "The password or email is incorrect."
    render :login
  end
end | 
 
    
      
  
  
    #logout  ⇒ Object 
  
  
  
  
    | 
28
29
30
31 | # File 'app/controllers/blog/gem/authors_controller.rb', line 28
def logout
  session[:author_id] = nil
  redirect_to blogs_path
end | 
 
    
      
  
  
    #new  ⇒ Object 
  
  
  
  
    | 
39
40
41
42 | # File 'app/controllers/blog/gem/authors_controller.rb', line 39
def new
  @author = Blog::Gem::Author.new
  @page_title = "New Authors"
end | 
 
    
      
  
  
    #update  ⇒ Object 
  
  
  
  
    | 
58
59
60
61
62
63
64
65
66 | # File 'app/controllers/blog/gem/authors_controller.rb', line 58
def update
  respond_to do |format|
    if @author.update(author_params)
      format.html { redirect_to "#{Blog::Gem.path}/authors/me/edit", notice: 'Author was successfully updated.' }
    else
      format.html { render :edit }
    end
  end
end |