Author: heridev

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]

Export and import from local to heroku From local run the following command replacing with your own values [shell] pg_dump --no-owner --no-acl -d db/padroncolima_development > yourdatabasedump [/shell] Upload this file "yourdatabasedump" into a public repository like S3( if that is the case dont forget to set public permissions to the...

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]

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

After thinking a little bit I don't remember writing too much about javascript and I really like javascript !!!, well here it is the first post that I want you to share with you guys. Sometimes you need to get the absolute url from javascript for those cases you can find useful the following function: [javascript] window.Utils = { httpUrlFor: function(url_params) { var domain, port; domain = "http://" + window.location.hostname; port = window.location.port ? ":" + window.location.port : ""; return domain + port + url_params; } }; # or in coffee-script window.Utils = httpUrlFor: (url_params) -> domain = "http://#{window.location.hostname}" port = if window.location.port then ":#{window.location.port}" else "" "#{domain}#{port}#{url_params}" [/javascript]

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.