Ruby

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]

Actually it is pretty straightforward you just have to download and use ngrok(it's free): [program] https://ngrok.com/ [/program] In my case I'm using a rails application so I just need to: [shell] # run my server in localhost rails server # at this moment it is available in http://localhost:3000 by default # if you want...

First thing you have to do is log-in to your server using ssh and going to the discourse installation path: [shell] # login in to your ssh account ssh youraccount@yourip.com cd /var/discourse [/shell] If you need to see the rails logs and see what is doing discourse the commands bellow are what you're looking for: [shell] # connecting to the rails application ./launcher ssh app cd /var/www/discourse #starts all the logs in console tail -f log/*.log [/shell]

Here you have the simple step you may follow: Go to your website and create a new user account Go to console [shell] bundle exec rails console [/shell] How to activate your discourse account manually(from console) if you are not receiving the confirmation email: [shell] token = User.last.email_tokens.first EmailToken.confirm(token.token) [/shell] Setup your account as an admin...

Sometimes when you're playing with new code it is kind of difficult to find out where they are declared or maybe this method are declared using metaprogramming and they are not explicitly declared: In most of the cases you can just copy your method or function and search it in the repository using ack http://beyondgrep.com/ or silver searcher(ag) https://github.com/ggreer/the_silver_searcher but if you are not able to find the method you're looking for using some of this searcher tools you can use some gem for debugging for example debugger https://github.com/cldwalker/debugger or pry https://github.com/pry/pry.

In the past days I attended the http://gophergala.com/ event which it was a really good start in the Golang world, I learned some stuff about Golang, after to read this previous sentences you are going to say WTF is this post about ruby or Golang well I wanted to start writting about the Gophergala because the code that we are going create is created with the aim and purpose of cloning all the repositories from an account in this case the gophergala organization using ruby in a rake task, Why Am I doing this? just to put in only one place all these great resources (I will put in my account all of this repositories in one repository).

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] ...

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]