Chris Oliver

Joined

290,710 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in Errors Following the Deploy Rails Tutorial

Awesome, making progress! :)

I think you might want to check your passenger_ruby line in nginx.conf to make sure it points to the right version.

Posted in Errors Following the Deploy Rails Tutorial

You may actually need to do this from the postgres user because it may be the only one that has admin permissions to do that. They set up their security permissions by default pretty well.

Check out this document https://help.ubuntu.com/community/PostgreSQL#Create_database

They mention:

 sudo -u postgres createdb mydb

I can't remember what I used to create my pg database last time, but that looks about right.

Posted in Capistrano deployment errors

That would do it. Subtle but important! :)

Posted in Errors Following the Deploy Rails Tutorial

Ah yeah, you need to run that in one of the releases directories (as long as your Rails code is in there). If there aren't any, you can create the database manually with the postgres command prompt.

Posted in Errors Following the Deploy Rails Tutorial

That command they suggest there is incorrect if the database doesn't exist. You can ssh into your server and run the following command to create your db, then your deploy should be able to run the migrations.

RAILS_ENV=production bundle exec rake db:create

Posted in Errors Following the Deploy Rails Tutorial

Is your database.yml created manually on the server or is it in your git repository?

Posted in Errors Following the Deploy Rails Tutorial

That's totally fine about environment variables. Been there too. ;)

I think you may want to try host instead of url. I've never used the url option before so that could be related. If the db is on the same server, you should use 127.0.0.1 instead of the public IP so that it doesn't have to connect to the outside world and it can run quickly internal to your server.

Posted in Capistrano deployment errors

I think (after looking at my server) that the ruby/1.9.1 folder is okay. I have a bunch of gems (420 apparently!) in that same ruby/1.9.1 folder and I've been using Ruby 2.1.5. It seems safe to ignore that bit.

The reason I think it is probably that is because the line #7 is this one and it is using the new version of the Ruby hash format

    def add_days origin, days, config: nil

Which would give you that syntax error if you were running on an older version of Ruby.

Now one thing to note here is Capistrano doesn't load up bash which means it wouldn't initialize rbenv or rvm (whichever you are using). So it is possible that if you don't have rbenv/rvm configured right in Capistrano, it may be loading a different version of Ruby that came with your server. That might be the next piece to do some debugging on.

The capistrano-rvm and/or capistrano-rbenv gems are probably the ones to take a look at here and make sure it's executing the right version during the deploy.

Episode 33 covers the basics of OAuth using Omniauth and Twitter as an example that might be helpful for you. https://gorails.com/episode...

Posted in Errors Following the Deploy Rails Tutorial

Yeah I was going to say, it seems like your Gemfile is missing from the git repo.

Sounds like you're just about finished with it! That last error sounds like your database.yml file might be misconfigured. It looks like you've got the IP address on the line where the adapter should be. Can you paste your database.yml file so I can take a look?

Posted in Capistrano deployment errors

That's interesting. Is the version of Ruby running on your server the same version as the one you have locally by chance?

Posted in Setup MacOS 10.10 Yosemite Discussion

I think we have all been there more than a few times. ;)

Posted in Setup MacOS 10.10 Yosemite Discussion

Your SQL server may not be running either just because it wasn't started or because of an error. You'll want to run "brew info mysql" and read the notes for the command to start the server. You can run it manually to see if it starts, and then if that goes well, you can run the launchctl commands to have it start on boot.

Solid!

Posted in problem with like link in nested resource

Oh of course. If you look at your routes, there is no POST paths there. I think you can change the resources :like to be singular instead like this: resource :like and that will help.

In either case, your rake routes should be creating a POST link to let you create a new like. It's odd that your current one doesn't have a POST route.

You could. I rarely have the need for going back to logs over 2 weeks old, so I don't keep them around. If you need to, you can always sync those somewhere.

Posted in Button Loading Animations with jQuery UJS Discussion

Yup! The libraries have a couple different helper methods. I got confused using the wrong gem the other day. ;)

Posted in problem with like link in nested resource

Hey Pablo,

Your link looks correct and so do your routes. Are you getting an error?

Posted in Token Auth API with Devise

That app is pretty good and I've used Devise token_authenticatable in the past and it works pretty well. I'd recommend using as long as you don't need something complicated with your API tokens.

I think doing an episode on using token_authenticatable and one from scratch would be great. Are there any particular things you'd like to see covered in an episode?

Posted in Performance increase over group_by

You could take advantage of Ransack for the search there. It has all kinds of nice things that can take care of searching and sorting. Take a look at the episode I did on it: https://gorails.com/episodes/forum-search-with-ransack

Two changes I would suggest, but depending on what you're trying to achieve, they might not be relevant:

  1. Your search by options aren't safe in that I can type ?search_by=destroy and it will send method call that to the user instance which could delete the records for example. That's a potential security problem so you will probably want to validate that better.
    @search_by_options = [:age, :location, :department, :designation]
    # Verify the search_by column is valid, otherwise default to location
    @search_column = @search_by_options.include?(params[:search_by]) ? params[:search_by] : :location
  1. If you don't plan on linking the user names anywhere, you could do the map inside the controller instead. That would make it a little bit more obvious in the views.
    @grouped_user_names = User.all.group_by { |user| 
      user.public_send(params[:search_by] || :location)
    }.map(&:name).join("||")
<% @grouped_user_names.each do |grouping_key, user_names| %>
  <p> <%= grouping_key %> : <%= user_names %></p>
<% end %>

And since the controller mapping is reasonably nasty, you could put that inside a class method on User or you could create a presenter class to handle the logic. I'd go with the class method at first until you have a handful that can be refactored into a presenter.