Class: Postnhost::LanguagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Postnhost::LanguagesController
- Defined in:
- app/controllers/postnhost/languages_controller.rb
Constant Summary collapse
- PAGE_SIZE =
15
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/postnhost/languages_controller.rb', line 32 def create @language = Postnhost::Language.new @language.assign_attributes(language_params) if @language.save redirect_to @language else render :new, status: :unprocessable_content end end |
#destroy ⇒ Object
51 52 53 54 |
# File 'app/controllers/postnhost/languages_controller.rb', line 51 def destroy @language.destroy redirect_to languages_url, notice: "Language was successfully deleted." end |
#edit ⇒ Object
30 |
# File 'app/controllers/postnhost/languages_controller.rb', line 30 def edit; end |
#index ⇒ Object
9 10 11 |
# File 'app/controllers/postnhost/languages_controller.rb', line 9 def index @languages = Postnhost::Language.order(updated_at: :desc) end |
#new ⇒ Object
26 27 28 |
# File 'app/controllers/postnhost/languages_controller.rb', line 26 def new @language = Postnhost::Language.new end |
#show ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/postnhost/languages_controller.rb', line 13 def show articles = @language.articles.includes(:article_snapshot, :categories).order(created_at: :desc) article_variants = @language.article_variants.includes(:article).order(created_at: :desc) @articles_pagy, @articles = pagy(:offset, articles, limit: PAGE_SIZE, page_key: "articles_page") @article_variants_pagy, @article_variants = pagy( :offset, article_variants, limit: PAGE_SIZE, page_key: "article_variants_page" ) end |
#update ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/controllers/postnhost/languages_controller.rb', line 43 def update if @language.update(language_params) redirect_to languages_url, notice: "Language was successfully updated." else render :edit, status: :unprocessable_content end end |