Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change the default layout and use route helper method in forem #625

Open
Byronlee opened this issue Dec 8, 2014 · 5 comments
Open

Comments

@Byronlee
Copy link

Byronlee commented Dec 8, 2014

That is the case, my existing Rails iproject integrate forem, I use rails g forem: views, custom-existing pages, but I found a few questions:

  1. forem views generated pages, unable to use my existing systems Rails route helper method
  2. forem views application.html it is not using the default layout of my original program, but it use othe default layout forem , forem / default.html

How to solve these two problems? Thank you

@bodrovis
Copy link
Contributor

bodrovis commented Dec 8, 2014

@Byronlee You have to prefix your existing routes helper with main_app. To fix the second issue you have to tweak initializers/forem.rb like this:

Rails.application.config.to_prepare do
  Forem.layout = "application"
end

I've written a guide on how to setup Forem: http://www.sitepoint.com/forem-rails-forum-engine/

@Byronlee
Copy link
Author

Byronlee commented Dec 8, 2014

thx, yes , you right,
the first issue, i try , touch a file :

/#{Rails.root}/app/decorators/controllers/application_controller_decorator.rb

ApplicationController.class_eval do
  helper Forem::Engine.helpers
  helper Rails.application.routes.url_helper
end

and i can user the man_app route helper ,but , i have a route helper like wikis_path, in the forem view ,it translate it to "/forem/wikis", but i don't neet the forem prefix. what shoult i do?

the second issue ,i have fix it by add Forem.layout = "application" in file initializers/forem.rb
but in the initializers/forem.rb document shows: Forem::ApplicationController.layout "application" . it not work. Give me a misleading. so you should update the document .

@bodrovis
Copy link
Contributor

bodrovis commented Dec 8, 2014

@Byronlee Not sure about the first one. The second one is a bug that is yet not fixed. It is supposed to be like said in the wiki but it does not work, so I've found this workaround.

@radar
Copy link
Collaborator

radar commented Jul 13, 2015

Is this issue ok to close now?

@bodrovis
Copy link
Contributor

Idk, it should be tested, but this used to be broken and we had to use Forem.layout = "application"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants