Dance Up is a software as a service (SaaS) web application built with Ruby on Rails. Other technologies used are jQuery, Bootstrap, and SCSS. Users can create a free account with limited user information access or a paid account with full access. Additionally, users can upload avatars and post status updates in their profiles. Payments are captured through Stripe. Mailers are handled by Sendgrid.
Built with
- Ruby
- Ruby on Rails
- Javascript
- jQuery
- HTML
- CSS
- SCSS
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
belongs_to :plan
has_one :profile
attr_accessor :stripe_card_token
def save_with_payment
if valid?
customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)
self.stripe_customer_token = customer.id
save!
end
end
end
class ProfilesController < ApplicationController
before_action :authenticate_user!
before_action :only_current_user
def new
# form where a user can fill out their own profile.
@user = User.find( params[:user_id] )
@profile = Profile.new
end
def create
@user = User.find( params[:user_id] )
@profile = @user.build_profile(profile_params)
if @profile.save
flash[:success] = "Profile Updated!"
redirect_to user_path( params[:user_id] )
else
render action: :new
end
end
def edit
@user = User.find( params[:user_id] )
@profile = @user.profile
end
def update
@user = User.find( params[:user_id] )
@profile = @user.profile
if @profile.update_attributes(profile_params)
flash[:success] = "Profile Updated!"
redirect_to user_path( params[:user_id] )
else
render action: :edit
end
end
private
def profile_params
params.require(:profile).permit(:first_name, :last_name, :job_title, :phone_number, :contact_email, :description, :avatar)
end
def only_current_user
@user = User.find( params[:user_id] )
redirect_to(root_url) unless @user == current_user
end
end
This project was written in Ruby 2.2 and Rails 4.1.0
-
Clone the repository:
git clone https://github.com/neillsom/dance-up YOUR_PROJECT_NAME
-
Move into the project directory:
cd YOUR_PROJECT_NAME
-
Install gems / dependencies:
bundle install
-
bundle exec rake db:create db:migrate
-
Create membership plans in database
$ bundle exec rails c
> Plan.create(name: 'basic', price: 0)
> Plan.create(name: 'pro', price: 10)
> exit
-
Start the application:
bundle exec rails server
-
App is now running on local host port 3000 http://localhost:3000/
MIT License Copyright (c) 2018 Neill Somerville