This is a simple structure build for personal blog/website. This is a Chinese version since the customer request. Will add I18n latter for international language.
Before deploy, configure your own google map key and put to app/views/static/contact.html.erb file.
https://www.google.com/maps/embed/v1/place?q=16%20Southwood%20Drive%2C%20Orinda%2C%20CA%2094563&key=..."
This template using Rspec-rails, FactoryGirl, Shoulda, and Capybara for unit test, functional test, and integration test. In order to run test, please using:
$ bundle exec rspec
The database is using default SQLITE3 because of the light data. You can deploy to heroku (have to use PostgreSQL for production). In order to deploy to heroku, please follow the following step:
-
First configure remote heroku branch: For more information, please visit devcenter.heroku.com/articles/git
$ heroku create $ git remote -v $ heroku git:remote -a falling-wind-1624
-
Know your database attributes: Go to your postgres.heroku.com/databases, and find the one your just create. It will looks like:
Host ec2-54-225-168-181.compute-1.amazonaws.com Database dsabcd1234jk User abcdefgh Port 1234 Password HASH
-
Copy all of them to the config/database.yml file:
production: adapter: postgresql encoding: unicode ...
-
Deploy code:
$ git push heroku master
-
Migrate database table if any:
$ heroku run rake db:migrate
There are two links for this simple website. One is for website admin, one is for other viewers.
-
For admin, go to yourwebsite.com/admin to login;
-
For other viewers, just go to yourwebsite.com to view;
There is a hidden link to create the admin username and password: Yes, like the comment said, uncomment them out.
-
Go to config/routes.rb file. You will see the following 3 lines:
# If you want to create a new username and password, please uncomment the following two lines out. # get "sign_up" => "users#new", :as => "sign_up" # resources :users
-
Go to yourwebsite.com/sign_up. Set up your favorate username and password. What you set will be the username and password for future Admin login.
-
Please go to config/routes.rb file, comment those code again. Since you don’t want anybody to be the superuser for your website.
The blog contains static pages and dynamic pages. Using ruby on rails as a framwork.
Usually there are some pages like home, contact us, resume, personal information are static page. So here I use a StaticController to redirect all those static pages.
The database just contains 3 tables: post, comment, and user:
-
Only admin can edit, delete, update the articles you post.
-
Anybody can leave comment for your articles.
-
User contains session and compare username and password hash when login for authenticate.
Even though the code is successfully configure twitter-bootstrap-rails gem file under rails version 3.2*, but failed to configure under rails version 4.0. So here I make bootstrap from CDN directly to avoid version issue. In this case, if your rails version is 3(like 3.2.8), you are able to use .scss file. Otherwise, you can only use .css file since .scss (–rails default) is conflict with .less (–bootstrap default).