This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mechanize' | |
require 'csv' | |
# Load up the trending Ruby repos on GitHub from the last month. | |
url_to_scrape = "https://github.com/trending?l=ruby&since=monthly" | |
# Snag the website with Mechanize & parse it into an XML document we can query. | |
page = Mechanize.new.get(url_to_scrape) | |
# Set the name of the CSV we'll create & load from. | |
file = "repo_data.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V1::SessionsController < Devise::SessionsController | |
before_action :sign_in_params, only: :create | |
before_action :load_user, only: :create | |
# sign in | |
def create | |
if @user.valid_password?(sign_in_params[:password]) | |
sign_in "user", @user | |
render json: { | |
messages: "Signed In Successfully", | |
is_success: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V1::RegistrationsController < Devise::RegistrationsController | |
before_action :ensure_params_exist, only: :create | |
skip_before_filter :verify_authenticity_token, :only => :create | |
# sign up | |
def create | |
user = User.new user_params | |
if user.save | |
render json: { | |
messages: "Sign Up Successfully", | |
is_success: true, |