spree

First thing first: Don't forget to setup the environments in my case for example: config/environments/development.rb [ruby] # mailer defaults config.action_mailer.default_url_options = { :host => "localhost:3000" } [/ruby] config/environments/production.rb [ruby] config.action_mailer.default_url_options = { :host => 'elh.mx' } [/ruby] And now let's add the helpers If you are just using the Rails you can do something like: [ruby] module MailersHelper def host_url_for(url_path) root_url.chop + url_path end end [/ruby]

Hello Guys, In this post I'm going to start putting all about queries in rails, so if you find any interesting query let me know and I can put it here, so let's get right to it: Something that I found really useful to understand how the joins works is using this image: If you want to retrieve all the orders that contain more than 2 shipments (Using Spree models) [rails] # this is using inner joins buy default from rails Spree::Order.joins(:shipments).group("spree_shipments.order_id").having("count(spree_shipments.id) > 2") [/rails]

How to apply a Spree coupon promotion within console: [ruby] # search the order in this case I'm using the last one o = Spree::Order.last # apply the coupon code you already create from the admin panel section o.coupon_code = 'order_discount' # apply the coupon code specified handler = Spree::PromotionHandler::Coupon.new(o).apply [/ruby] ...

As you know there is a free plan in heroku.com and you can use only 10,000 rows in the database but sometimes your database exceeds those limits and you don't want to pay because the app installation in only for testing purposes. That is why you can use the following commands if you want to to search and find the tables that have the maximum number of records and be able to delete the ones that are not necessary for you

Just for future reference in Spree you can use the following code in spite of authenticate an existent user created in a Spree Store [javascript] var server = 'http://localhost:3000'; var userAuthUrl = server + '/login.js'; var data = {spree_user: {email: "spree@example.com", password: "spree123"}} $.ajax({ type: "POST", data: data, url: userAuthUrl, success: function(data, textStatus, jqXHR) { console.log(data); console.log(textStatus); console.log(jqXHR); } }); [/javascript]

Hello guys I want to share with you about this problems with wrong color or quality for the uploaded images using Paperclip gem, Imagemagick and Heroku.com. The fix that we did it is related with the Imagemagick configuration and updates in order to fix this problem you have to do the following actions: First you have to set a new environment variables on heroku running the following command:

I decided to add a new image for a product in spree and in that scenario there is a generator provided by paperclip with the purpose of generate that new attachment I tried to run the following command: [shell] rails generate paperclip spree_products specs [/shell] Buuuuuuuut I received the following error: `migration_file_name': protected method `migration_file_name' called for # (NoMethodError)