6,830 Experience
65 Lessons Completed
0 Questions Solved


Posted in Your First Ember App Discussion

Thank you for your reply! so I guess in this case you would also deploy on two different machines/droplets (if you are using DigitalOcean for example) is that correct? How would the backend communicate with the frontend?

@Christophe Estanol

Have you manage to solve this issue with the turbolinks caching has mentioned? I have intalled the jquery-turbolinks gem and restart the server as per the comments of another user but the isse still occurs

Posted in Your First Ember App Discussion

I have a question. If you have an app that is developed on Rails on the backend and Ember on frontend, would you keep both frontend and backend on the same repository, or on two different ? If the 1st case is the correct, then I guess both would live under the root (app name) folder right? something like this

- app-folder (git-init here)
-- backend (rails api)
-- frontend (ember)

Posted in Deploy Ubuntu 16.04 Xenial Xerus Discussion

I'm planning to do a fresh OS installation on my local machine, so I have a question: is there a way to backup my existing ssh keys that I use to login to the server or my repos, or do I have to generate and add a new key in this case? if thats the case I guess all I need to do is to generate the new key on my fresh install and ssh-copy-id to the server again??

I'd like to ask a question.

Lets say we have a web app that uses Rails api on the backend and Ember on the front end. The folder structure I guess would look like this:

- backend (rails api)
- frontend (ember)

In this case how do we create a repository and push the app on github/bitbucket?
a. all in one repo
b. use different repo for the backend/rails and different for the frontend? if thats the case how do we deploy on production/staging both repositories?

Posted in Deploy Ubuntu 16.04 Xenial Xerus Discussion

Just to confirm, firstly the domain need to buy in godaddy or some similar, correct? I don't think you can do this with Digital Ocean

Posted in Deploy Ubuntu 16.04 Xenial Xerus Discussion


you can create the database.yml same way as you did with secrets.yml. Create an empty file in same place where secrets.yml are and then copy the code from your local copy (ie development env). You have to set the credentials accordning to the ones you have set on production obviously :-)

To create the files (assuming you are connected on server) cd into your shared/config/ folder and then type touch database.yml and touch secrets.yml

Posted in simple mde duplicates

@Chris After spending almost half a day on searching why the bug was still occuring even if I tried your code, I finally found the solution from this answer on StackOverflow, as I was also getting this error on firebug

jquery-ujs has already been loaded!

When I moved javascript_include_tag from the footer inside <head> the error and the bug was gone!

Posted in simple mde duplicates

I have the same issue

simplemde = null

$(document).on 'turbolinks:before-visit', ->
  if simplemde?
        simplemde = null

$(document).on 'turbolinks:load', ->
  simplemde = new SimpleMDE(
      element: $('.simplemde')[0]
        spellChecker: false

See my screenshot

Posted in SimpleMDE & RedCarpet

I have a similar problem. When I 'm on the edit action the content of the textarea I'm having the SimpleMDE is diplaying indented like you see on the screenshot


So if I understand correct,

1) I create assets/stylesheets/admin.css (or .scss) and assets/javascripts/admin.js (or .coffee)

2) add in config/application.rb: config.assets.precompile += ['admin.js', 'admin.css'] as you said

3) and then in my admin layout I do: <%= stylesheet_link_tag "admin", media: "all", "data-turbolinks-track" => true %>

correct or did I lose something ? Also same thing applies if I want to do same thing for the frontend too ?

I've a question which I think is related with how to organize the assets files. If we have a rails app that has both a custom frontend and admin/backend layout (so basically we have some controllers inside an admin folder and admin namespace), how can we specifiy in this case that the admin will load only assets required for the backend and not the frontend (and vice versa) ?

Posted in Environment Variables | GoRails

I notice it says rbenv. I'm having rvm, is there any similar in this case?

Posted in Environment Variables | GoRails

I have a question regarding ENV variables.

Suppose I have just a single Rails appon my Development environment. Then in this case I could use ENV vars to save my db credentials, so I could do something like this on my bashrc file:

export DB_USERNAME="my-username"
export DB_PASSWORD="my-password"
export DATABASE="railsapp_development"

This seems pretty straight forward but what there are more than one project on the development environment? I guess the username and password are same, but the database name changes on each project because projects don't usually share the same database, right?

How to use a different database name for each project in this case then?

That would be nice to see!

Nice! just a (silly) question: if the plugin - eg a slider - we want to use includes icons, like "pause", "play" or navigation buttons etc, then in this case need to add them on a vendor/images folder and set the paths (relative) on javascript properly to link to the icons and not seem broken, right?

Posted in Keeping track with Annotate Discussion

Ah, I see, my bad.. So this works fine and in rails 5 then

Posted in Keeping track with Annotate Discussion

I've installed annotate on Rails 5,but I noticed when I run the g annotate:install that it creates a .rake file. Is it ok to use this on rails 5, because as far as I know the rake is depricated and use rails instead

Posted in Workflow for TDD/BDD on Rails ?

Hi, I'd like some feedback if possible about the workflow of TDD/BDD on a Rails app. I was doing a research the whole weekend trying to find some good examples on how to do porperly TDD on my Rails apps, but most of the resources (especially with Rspec) seemed a bit outdated as they were using older versions or I wasn't happy enough with the content of the resource.

However I think I've manage to come up with how TDD is done in Rails and I'd like to try and describe it to you with a simple example and then if you could tell me if I have understand it correct or not. Lets go to my example:

Lets assume that we want to build a simple blog and for the tests want to use Rspec, Capybara, FactoryGirl etc etc (I picked these gems as an example, but I assume same thing would apply if we used minitest instead of rspec or with any other gem). In most examples I've seen they start testing by writing a first test (as TDD suggests) like this:

// visit the root page
// click the link "New Post"
// submit the form (eg title and body fields)
// expect the page to display the new post

And with a combination of Rspec and Capybara we write a test like this and we run it every single time in order to write the minimum required code until the test pass. And then we keep going to the next one, and the next one etc etc, until we come up with a completelly restfull PostsController.

Ok, this seems quite nice, but what if we know right from the begining that we need to create this restfull PostsController? Wouldn't make more sence to generate a scaffold Posts and then do the tests? So the steps would be

  1. rails g scaffold Post title:string body:text
  2. write a test like the one above to see if we can create a post etc etc

So, I think we are not doing exactlly TDD in this case, but still we do testing.

Regarding organizing our tests, I've seen in a few resources doing something like this:

  1. have /spec/features directory where we can write tests that are related with the "user interactivity", so tests that cover things like click this link, submit this form, expect to see this content on my webpage etc
  2. have the /spec/models for testing the models, like validation rules, scopes, methods etc etc
  3. have the /spec/cotrollers for testing controllers in the same way as we do for models

Is this how TDD is supposed to be done? and is this the proper way to organize our tests then ?
I'd appreciate if you could give me your feedback on this.

Thank you for your reply Chris!

Is this the most efficient or correct way of setting things then? Or is it better to use gemsets instead? Cause as far as I understand now all my gems are installed in a "global" scope. Also if that's the case (using gemsets) how can I create gemsets for my existing projects (old)?