Issues with replacing Spree Commerce layouts? - ruby-on-rails

I am currently starting to build a custom frontend for a Spree application and I was wondering how to go about it.
I have read the Spree Commerce Documentation and it sais there are two ways of customizing views.
the Deface library
replacing the views in the Rails folder
In the docs it is stated that
Whenever you copy an entire view into your extension or application you are adding a significant maintenance overhead to your application when it comes to upgrading to newer versions of Spree. When upgrading between versions you need to compare each template that’s been replaced to ensure to replicate any changes from the newer Spree version in your locally copied version.
To this end we strongly suggest you use Deface to achieve the desired customizations wherever possible.
I would have to replace all of the front-end views but I am afraid that this will prevent me or others to update to another version of Spree. Defacing seems a bit overly complicated in my case...
Can anyone tell me how big of a problem replacing the views will be in regard of the above stated?

There are around 48 views in the front end of Spree. By replacing all of them in your own application, every tie you want to upgrade Spree, you will need to determine what has changed between your views, and Spree's views between the two Spree versions, check if any templates have been added or removed, and then figure out how to modify your views to conform to the expectations of a new version of spree. This will be a lot of work.
I'd recommend you re-evalute why you need to change all of Spree's views? Take a look at the spree_fancy extension. They are able to completely change the look & feel of Spree while only replacing a small subset of the views, and using Deface to add content and markup where needed. An extensions like this would be much easier to port to future versions of Spree than if they had replaced all of the views. We manage many Spree sites, and have several significantly customized front ends, and have not yet had to resort to techniques beyond Deface, and CSS changes.
If your front end is radically different, and using the existing Spree front end will be too cumbersome, you may want to consider building your front end using the Spree API. The API is designed to have more stable inputs and output between versions, which will make upgrading Spree much easier.

Related

Integrating multiple apps in Rails

I am working on a project in Rails. It contains multiple sub-projects. They have a common login and the rest is separate for all. I want to integrate them all in the main project. The sub-projects are pretty big, so putting them all together will make it cumbersome to manage the code. Is there any way to integrate the sub-apps or gems in the main project?
You might consider breaking your apps into engines. It's a great way to isolate functionality and make code modular. Here's a link to the Rails engine docs: http://guides.rubyonrails.org/engines.html
If you need examples of real-world uses of engines you might consider looking at the code for Spree: https://github.com/spree/spree
With Spree you can add custom functionality by installing or building extensions, which are effectively Rails engines.
If you want to reference local gems/engines, you can point to them in your Gemfile like this:
gem 'mygem', :path => '/path/to/gem'
But make sure that the individual gems within your project don't have a .git folder, or you might run into errors regarding sub-modules.

Overriding the default views in RailsAdmin

I am using Ruby on Rails 4.2.1 with RailsAdmin. The gem works excellent, but I have the requirement that the layout of the admin panel and the forms must look different than what is generated by default. For example, the navigation should be horizontal top, the forms should order the fields in two columns.
So far I haven't find a way to copy the views locally and modify them (like in Devise for example). I have tried to replicate the views manually in the respective path under my views folder by copying the original views, but I got problems with the helper methods that are part of RailsAdmin not being accessible from my views.
I dug deeper and found that there is a task copy_views, it was referred to in questions for the older versions of the gem, but if I try to use it now rake rails_admin:copy_views, it is not available anymore.
Am I doing something wrong, or is there another way to do this?
You can create folders in your app
app/views/rails_admin/main for https://github.com/sferik/rails_admin/tree/master/app/views/rails_admin/main
app/views/layouts/rails_admin/ for
https://github.com/sferik/rails_admin/tree/master/app/views/layouts/rails_admin
Put modified files there. It can get a little messy and you will need to update the files if the gem changes.

Can an admin template be used in a Ruby on Rails web app?

I have been doing UI research and have come across admin templates at http://themeforest.net/. I was wondering how do you apply these onto a web app built on Rails. These templates look very similar to wordpress themes. Are they that easy to configure? Is it just as simple as setting up a link to the database to make the fields form capture data? I've been looking at this theme.
For admin templates I recommend using Active Admin. It's relatively easy to implement and gives you great admin screens with little effort.
Yes, You can. I'm trying to solve the same problem and so far I have a couple options:
1.) do it by hand, I've done this before, it works but takes a lot of time to truly understand how your theme is put together. First I would recommend using the included themes assets exactly as they are bundled with the theme. Don't assume that just because you have twitter-bootstrap-rails gem that the bootstrap classes in the theme will work. Link the assets statically and slowly extract out the static assets and replace them in the asset pipeline once you know they work.
2.) Use the strategy suggested in the install_theme gem (http://drnicwilliams.com/2009/10/06/install-any-html-themetemplate-into-your-rails-app/) the gem itself is not maintained any longer (i'm not sure about any forks), but the strategy is sound. Extract the core parts of the template into partials.
The short answer is yes, but there is no straight forward way to "import to rails"

changing complete layout in spree

I am working on spree 1.0.0 and have been doing some research on it
for my e-commerce site.
I have already made and used some existing extensions in my app. Now,
I am working on layouts and have been trying to figure out that what
are the best possible ways for that.
My need is that I have to change the complete front end layout of my
store in comparison of what spree provides.
Some of the options from my point of view are
-> Use an extension to write all the views that overrides the templates that spree provides,
-> Use Deface to override views (which would be hectic as I have to change approx everything on almost every page)
-> Use mixed functionality of the above options.
or is there another way to do this.
thanks in advance.
You are likely to have a new issue soon: to tell your new controller to use your new spree_application layout.
The spree google group indicates that you can use inheritance to use the main application everywhere: https://groups.google.com/forum/?fromgroups#!topic/spree-user/mB02WqMnCnw%5B1-25%5D
However, I still haven't figured out how to solve the routing for those controllers.
You can do this by overriding the app/views/layouts/spree_application.html.erb by placing an identically named file inside your application's app/views directory.

ruby on rails 3.1 web design

May I ask you how to make rails web design more efficient?
Is compass plus blueprint the perfect match?
Is the current version of compass support rails3.1
Are there any other frameworks that will make rails web deign easier?
Thanks
Definitely a framework like compass is awesome, it includes a lot of helpers, and provides a good solid base.
For form-styling I would recommend using a gem like [formtastic][1], which not only greatly simplifies making forms, but also provides a standard css file. So all needed tags are then known (and can be overwritten if needed).
There a few alternatives to kickstart your application's layout:
twitter-bootstrap: it is plainly awesome and provides a great start (it does not play nice with formtastic, but works perfectly well with simple_form).
web-app-theme provides generators, and a set of templates to style your application quickly
activo is a template that is contained in web-app-theme, but can also be used standalone
Hope this helps.

Resources