How to add an extra controller method to a rails application but not overwrite the current controller?

I use Spina CMS and he needs a routing mechanism to populate the front end from the back.

Therefore, I cannot interfere with this because I still need my CMS website, however I would like to add another action to my homepage / all pages in addition to what Spina does.

Is it possible?

Engine spina routes.rb:

Rails.application.routes.draw do
  mount Spina::Engine => '/'
end

I want to add my own controller and action:

class Default::PagesController < ApplicationController
    def homepage
        @thisisavariable = "hello"
    end
end

but if I add it to route.rb, it will overwrite Spina:

Rails.application.routes.draw do
  get '/', to: 'default/pages#homepage'

  mount Spina::Engine => '/'
end
+4
source share

Source: https://habr.com/ru/post/1695562/


All Articles