Editing page views with Irwi Wiki gem in Rails - ruby-on-rails

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.

Related

No Template for interactive request rails

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.

How to find spree account view source code

recently I had a need to modify a view template of the Spree e-commerce. According to the guides, I need to run bundle show spree to view current location of the spree gem and then copy view templates from there. https://guides.spreecommerce.com/developer/view.html But the target folder does not contain views folder << account >>, also I did a search for particular word 'favourites', no results. Maybe I need to install other gem, like spree_frontend or other? Can someone please help to find views to change?
I am not familiar with Spree but it looks like you're supposed to write/customize your own template using Deface. There is no "account" file in the source tree. To search go to their github, click the backend directory, click "Find file" and enter "account"... seems there are no results.
Later edit: you might want to look at these templates here:
https://github.com/spree/spree/tree/master/backend/app/views/spree/admin/users
I think one of them is used for the "account" method. If you're trying to edit the admin account edit page for instance, it's the users/edit.html.erb template.
If you are using devise with spree you want to look for account and auth related views to override in spree auth devise gem views
https://github.com/spree/spree_auth_devise/tree/master/lib/views

How do I theme a Spree website?

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.

Find url for webpage based on a partial file

I was introduced to a large team and not very familiar with the site I am developing for. I need to make an edit to a partial (i.e. _partial_file.html.haml) and need to verify the change visually but I don't know where that partial is being displayed on the website. Is there a way I can get a url from a partial file with rails.
For example, could I run a rake routes | grep or do something in the rails console to help find any URL where the partial is displayed?
Thanks
If I understand you correctly. While in your rails app root.
grep -r "partial_file" .
This will allow you to look for instances of partial_file and where it's being rendered. You might see it in a view or a controller. Depending on where you find it, you can rake routes and see just what url you should enter to see your output
When you render a page you should see output in the console for all templates being rendered.
example rendering template show.html.haml from SomeController#index
Use this to locate the template that is including your partial. You can then use that to search the entire project for all templates including that partial.
Rails renders templates by a specific convention that maps controller methods to specific layouts and templates. I would familiarize yourself with http://guides.rubyonrails.org/layouts_and_rendering.html to get a better idea of how the default internals work for you rails app and use that as a starting point.

Ruby on Rails generating controller with existing folder

I'm really new at this and I don't want to mess up my current application. I'm currently working on HTML/CSS stuff but I have a little understanding as to how to get things working.
I created a new controller by just doing
rails generate controller sign_up
I've created a index file (index.html.erb) inside sign_up folder from rails that automatically generated. Now I wanted to add more files, can I just add more files by typing in
rails generate controller sign_up send_page more_page other_pages
Will send_page, more_page, other_pages be automatically combined into the existing sign_up folder? Is this the correct way of adding pages if I want rails to add other files automatically? I just want it to ruin what I have so far so I don't want to try it for myself because I'm still really new to this,
Thanks!
To answer your question :
New files will be added to the existing folder but existing files will not be merged, you'll have to resolve the conflict by choosing between old and new files.
It seems to me you're trying to use generators for every action you need in your app :
Scaffolding is great to have a sample structure, but as soon as you start building your controller for real you need to move away from it : extend the controllers, models and views by hand. It's the only way you'll start to really understand how things are working.
If you run the generator again, it's going to complain about conflicts with existing files. Then you'll have to choose to overwrite (losing your existing changes to e.g. the controller), or not (in which case you won't get the new auto-generated methods, etc.).
You can just create a new controller action and a new view for each additional page you want to add (and a unit test, of course!). If you're using non-standard/non-restful action names, you'll also have to edit config/routes.rb to route them.
Looking at the names in your example, and your reference to "pages", I suspect what you really may want to do is create separate controllers for send_page and more_page. If that's the case, you'd run the generator separately for each new controller.

Resources