I have an existing website with model data and hundreds of entries. I want to give the catalog e-commerce functionality, so I decided on Spree.
However, I can't figure out how to connect my models data with products in Spree. Basically, all I need to do is add a price to existing data, as well as checkout functionality. I do not want to have to re-add all previous entries.
Anyone have a resource I could read, or thoughts on implementing this?
Is this still what is used?
https://github.com/joshmcarthur/spree-import-products
I'm using the newest version of Rails, ruby 1.9.3 and Spree 2.0.0.beta
Thank you.
Did you get a chance to have a look at this Spree Railscast (http://railscasts.com/episodes/298-getting-started-with-spree)
Your old catalogue schema will probably not be compatible with Spree's Product and Variant models so you'd probably have to write a simple Rake task to do this job, along these lines:
LegacyProduct.all.each do |legacy_product|
Spree::Product.create(:name => legacy_product.title, // etc.
// create variants etc.
end
Related
I'm a bit of a Rails beginner, so I'm sorry if this question is easy. I'm wondering how I am supposed to modify the Rails database as a developer without letting users of the site modify data.
More information:
Let's say I am trying to create a website that lists books along with their information. I want users to be able to see these books, but not add/delete them. As a developer, I want a way to add books without using the command line (hard to edit mistakes). What's the easiest way for me to do this? Would there be any differences between the development database and a live hosted one?
I think there are a few approaches to do this.
different user roles. This technically breaks the rule of without letting users of the site modify data, but being able to differentiate between normal and admin users means you can limit who actually can add data into the database. I used cancancan as a way to authorize requests but I know there are others.
I agree doing it using the command line isn't ideal, but rails do support rake tasks. You can create a task that will handle most of the logic and all you need to do is something like
rake create_book["name here"]
This will make the process less error-prone.
Create data using rails migrations. Rails can generate the skeleton file for you, and you just ran any ActiveRecord methods. However, the main purpose of migration is to update the database schema, but they can seed the database as well. here's the example from the dcos
Would there be any differences between the development database and a live-hosted one?
Yea, they should be totally separate database instances. You don't want to have your development database be the same as the live one. This would cause major problems. Rails have a concept of environments where you can use different configurations, so you can pick and choose what database URL to use.
like #davidhu said here The best approach really is the use of authorization. If only admin can see a page to CRUD the books then you don't have to worry about normal users doing same plus it makes it easy for you as the admin to make changes or add to the collection. Add the gem (or reinvent the wheel) then Rails will take care of the rest for you.
I'm new in Ruby on Rails, I'm wondering, is there a user interface to see all the data that you have in your Active Record Models and manipulate them just like PhpMyAdmin?
Sadly no - you have to write that interface yourself... :)
There are ways to quickly scaffold up an interface for each of your models. Look at doco on rails generate scaffold for more info.
There are also gems that will automate some admin-scaffolding for you:
Look at eg ActiveAdmin
But in practice nobody keeps either of these around for long in their projects (for various reasons).
If you're new to Rails, I can highly recommend reading your way through the Rails Guides here: http://guides.rubyonrails.org It will help you level up in all the fundamental aspects of Rails :)
There are gems in rails to maintain tables in rails app:
ActiveAdmin: It provides admin panel using which you can add/update/delete any record under tables.
rails_db_info: Just and it under Gemfile and run bundle install. Go to "/rails/info/db" link, it will list all tables with schema details. Its very easy to integrate.
I want to implement basic shopping cart functionality in my Rails app....are there any good gems that will make this process simple?
i.e. I want the shopper to be able to add products and quantities to their checkout, and I want the admin to be able to add new products to the store (and edit/delete existing ones).
Suggestions?
There is a wide range of payment and eCommerce gems covered at Railscasts.
A list of gems can also be found at The Ruby Toolbox and here too.
Also, not covered, you can use the Saas product Shopify
There are few:
https://github.com/spree/spree
Engines, plugins, big, no good i18n
https://github.com/piggybak/piggybak
Engine, plugins, no i18n, new project and still a lot of changes
https://github.com/nimbleshop/nimbleshop
http://www.ror-e.com/
https://github.com/potionfactory/potionstore/
Not an Engine
maybe you can try https://github.com/crowdint/acts_as_shopping_cart
That gem good for simple cart. Maybe you need little modify if you need update cart functionality
The list of a few is good,
and now there is one more engine: RubyClerks
It's small and simple, but all that small businesses needs.
And so it uses much less memory than others.
I'd like to be sure if vestal_versions does support versioned associations (it seems like it doesn't) before switching out to another versioning gem that can support versioned associations e.g => has_versioning. I haven't looked at the code yet but I couldn't find anything related with versioned associations from the readme file or the issue section on github. Help would be appreciated!
(At the moment of writing this) There is an associations branch in the official vestal_versions repository, It is still a basic idea and isn't merged yet in the master branch. So I decided to go with another versioning gem, specifically acts_as_revisable following the instructions in this blog post.
I'm looking for something that appears to be very close to your needs. But I don't need to revert the associated objects, just to record them. I was thinking of handle it in a nosql way. So I can save the model version and the associations would be embedded documents.
So I can compare versions in a more comprehensive way. Right now I use paper_trail, but as it can't handle associations, it's not possible to store the tags associated to a model and see how it changes through time.
If all I have is one model (for example Wiki) and want to save it along with its versions, I could use acts_as_versioned plugin which stores the wikis in "wikis" table and its versions in "wikis_versions" table. This is plain an simple even if I want to moderate the latest version before showing it to the public using a field as status with "pending review/ published".
What's the best way to handle Wiki with associations (for example attachments, assets,..) which also have versions? And how would you moderate it? Do you create a new version to wiki even though only its association is changed just to keep the flow going, if so what about other associations?
What's the best way to handle it with little db overhead?
Thanks in advance.
I have used both acts_as_versioned and acts_as_audited.
I prefer the latter because it uses a single table. Using acts_as_versioned we've had issues with changes to versioned tables requiring extra migrations => this adds extra complexity to our build and deployment process.
Richard Livsey has a nice plugin for this that works with acts_as_versioned.
http://github.com/rlivsey/acts_as_versioned_association/tree/master