Class: BlogBoi::ArticlesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- BlogBoi::ArticlesController
- Defined in:
- app/controllers/blog_boi/articles_controller.rb
Instance Method Summary collapse
-
#category_index ⇒ Object
GET /articles/category/cool_category.
-
#create ⇒ Object
POST /articles.
-
#destroy ⇒ Object
DELETE /articles/1.
-
#edit ⇒ Object
GET /articles/1/edit.
-
#index ⇒ Object
GET /articles.
-
#new ⇒ Object
GET /articles/new.
-
#show ⇒ Object
GET /articles/1.
-
#update ⇒ Object
PATCH/PUT /articles/1.
Methods inherited from ApplicationController
Instance Method Details
#category_index ⇒ Object
GET /articles/category/cool_category
61 62 63 64 65 |
# File 'app/controllers/blog_boi/articles_controller.rb', line 61 def category_index @articles = Article.with_category_name(params[:category_name]).where(hidden: false) @category_title = params[:category_name].titleize render :index end |
#create ⇒ Object
POST /articles
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/blog_boi/articles_controller.rb', line 35 def create @article = Article.new(article_params) if @article.save redirect_to article_path(@article.slug), notice: 'Article was successfully created.' else render :new end end |
#destroy ⇒ Object
DELETE /articles/1
55 56 57 58 |
# File 'app/controllers/blog_boi/articles_controller.rb', line 55 def destroy @article.destroy redirect_to articles_url, notice: 'Article was successfully destroyed.' end |
#edit ⇒ Object
GET /articles/1/edit
31 32 |
# File 'app/controllers/blog_boi/articles_controller.rb', line 31 def edit end |
#index ⇒ Object
GET /articles
11 12 13 14 |
# File 'app/controllers/blog_boi/articles_controller.rb', line 11 def index @articles = Article.all.where({hidden: false}) @articles_hidden = Article.all.where({hidden: true}) end |
#new ⇒ Object
GET /articles/new
26 27 28 |
# File 'app/controllers/blog_boi/articles_controller.rb', line 26 def new @article = Article.new end |
#show ⇒ Object
GET /articles/1
17 18 19 20 21 22 23 |
# File 'app/controllers/blog_boi/articles_controller.rb', line 17 def show @meta_tags = { title: @article.title, description: @article.description, image: @article.image.attached? ? main_app.url_for(@article.image) : nil, } end |
#update ⇒ Object
PATCH/PUT /articles/1
46 47 48 49 50 51 52 |
# File 'app/controllers/blog_boi/articles_controller.rb', line 46 def update if @article.update(article_params) redirect_to article_path(@article.slug), notice: 'Article was successfully updated.' else render :edit end end |