I want to alter the views of a mounted engine called Monologue
I've found this in the docs:
Monologue.layout = "layouts/monologue/application" # set the layout you want to use if you want to use your main_app layout
Which adds the main template, I'd rather change the engine views directly.
Where are those files located? I couldn't find them at the root of my app.
The previous answer is incorrect. Don't edit the gem files directly or your edits won't survive updates.
The correct way to modify the Monologue engine's files is to copy the gem's view files into the host application's /views.
For example, create application.html.erb inside host_app\app\views\layouts\monologue and edit that file. Your rails app will hit the custom view file and instead of the default ones in the gem. You can customize any Monologue view or partial in the same way, by simply duplicating Monologue's path in your application's views.
See all the files you can modify in this section of the Monologue github repo.
Edit: More information on customizing Monologue can be found here.
Gem files are located in .rvm or .rbenv folders which ever you are using.
rbenv:
$HOME_DIR/.rbenv/versions/#version_no/lib/ruby/gems
rvm:
$HOME_DIR/.rvm/gems/ruby-version
Related
Trying to add one route and respective controllers and views but getting error.
Tried with adding erb file in views folder.
Hard to diagnose with the little information you’ve provided, but given this statement:
Tried with adding erb file in views folder
It sounds like you’ve place your index.html.erb which corresponds to your MainController directly in your views folder.
Rails expects this to be located within a folder that reflects the controllers name. Ie views/main
I recommend checking out the official documentation to learn more about how everything flows.
What's the best way to edit and format page views using Irwi Wiki in Rails?
Here is the controller it's set up for me:
class WikiPagesController < ApplicationController
acts_as_wiki_pages_controller
end
Though there's no views folder corresponding to the controller. I just want to be able to edit the html or add css to the wiki articles I can create now.
https://github.com/alno/irwi
As it says in the docs:
You may create your own templates for controller actions (show, edit and history), in other case default built-in templates will be used.
So, in your views folder, create a folder called wiki_pages and then put your new templates in that folder.
Here's what's going on:
When your WikiPagesController currently goes to render a wiki page, it looks for a template in apps/views/wiki_page corresponding to the current action. That folder/file doesn't exist, so it looks in other directories and ultimately finds the template in the gem. (You should be able to see this process in your console.)
When you create the folder and add the template (as above), the WikiPagesController finds the template in your application and renders that, instead of rendering the template provided by the gem.
So I have done a little research and I think you can just copy all files from here: https://github.com/alno/irwi/tree/master/app/views/base_wiki_pages into views/wiki_pages folder so you will have all views locally and you will be able to edit them.
I've been trying to override rails_admin views inside a custom theme that I've built (which so far only overrides css).
Is it at all possible to override rails_admin default views (like the dashboard for example), inside my theme?
PS: Simply putting the views inside an app/views folder inside the theme doesn't work.
I've reached a possible solution, that, at first glance, seems to solve my issue completely.
After having a look at the rails plugin/engine mechanics, I noticed that, in order to include the plugins app folder and override other plugins (in this case rails_admin), I would need to require that folder on the gemspec file.
When using the rails_admin theme generator, this file is configured to only include the lib and vendor folders of the plugin.
In summary, i had to change the .gemspec file of my theme and include the app folder, like so:
s.files = Dir["{app,lib,vendor}/\*\*/\*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
I hope this helps anyone in a similar situation in the future.
I'm creating a spree e-commerce site and was wondering with the current updates to spree how to theme the default pages ( product, home page ) since I can't seem to find the files to do so.
You will need to create the views for the frontend. First understand the idea of how default views are shown.
The default views are located in spree-frontend gem. Check this out.
https://github.com/spree/spree/tree/master/frontend/app/views/spree
If you want to change the theme for only some parts, add the views for those parts only. If you want to change everthing, add all the views here.
For example, if you want to change the layout and the home page only, for layout you create
app/views/spree/layouts/spree_application.html.erb
and write your own layout.
for home page you add your html and template to the file
app/views/spree/home/index.html.erb
similarly you can change all the templates for the pages you want. That is how you change the theme.
Note:
you cannot find the files for the views because, the are located in the gem file.
Update I
To avoid having assets from gems, you can edit vendor/assets/javascripts/spree/frontend/all.js and vendor /assets/stylesheets/spree/frontend/all.css
for example to remove the default assets for spree_static_content you can remove the line
*= require spree/frontend/spree_static_content
Similarly you can also override the entire css and js, or partially
To replace an entire stylesheet as provided by Spree you simply need to create a file with the same name and save it to the corresponding path within your application’s or extension’s vendor/assets/stylesheets directory.
For example, to replace spree/frontend/all.css you would save the replacement to your_app/vendor/assets/stylesheets/spree/frontend/all.css.
This same method can also be used to override stylesheets provided by third-party extensions.
Its explained very well in details in:
spreecommerce' documentation
If you have any confusion with you, please comment and i can help you.
I'm new to rails and I've set up a standard spree e commerce solution. I now want to customize the default templates and styles. According to the spree documentation [1], the best way to do so is using Deface. Unfortunately, I can't figure out the location of the existing views/layouts.
For example, while the document suggests:
For example, to override the main layout, create the file YOUR_SITE_OR_EXTENSION/app/views/spree/layouts/spree_application.html.erb
my app/views folder doesn't contain a folder called spree
Can anybody tell me, how to change the view templates?
Thank you.
[1] https://guides.spreecommerce.com/developer/view.html
You have to actually create that directory and every directory along the way until you reach the file you wish to override. If you run these commands from your root directory you should be good to go.
mkdir app/views/spree
mkdir app/views/spree/layouts
touch app/views/spree/layouts/application.html.erb
Then copy the content from here: https://github.com/spree/spree/blob/master/frontend/app/views/spree/layouts/spree_application.html.erb into the file you've just created.
If you restart your web server you should be able to make changes to the local application.html.erb file and see them locally.
Any time you want to override a template completely, you can find the template you need to override on Github: https://github.com/spree/spree and recreate the necessary files/directories. Spree will look for templates in on localhost before the gem, so as long as you override the right template in the right directory, you can customize any view you like.
Alternatively, you can try running the rails generate spree:frontend:copy_views command to pull all the views you need from gems, and anything that is missing can be added manually, in strict accordance with the gems folder hierarchy. For example, in gems is parsl in the following spree_backend/views/spree/admin/users/_lifetime_stats.html.erb. To enter the desired code, I have to make a folder on the following path - the name of the project/app/views/spree/admin/users/_lifetime_stats.html.the erb and all the changes I will make here will fall into the main view code. This is an alternative to Deface::override