Creating a Blog using Ruby and Rails- Part 1
--
Summary: I wanted to create a unique blog for myself with various features created from scratch. I also had a special interest in learning ruby and rails and i decide what is a better way to learn than working on something practical. Something i really wanted. I have decided to embark on this journey and to document my challenges and resolution. This may help someone who may face similar issue i faced while learning rails and creating my own blog.
Environment & Development Tool.
I don’t want to waste time with the hefty setup and i wanted to have an environment where I can code from anywhere with an internet connection. Therefore I choose use Code anywhere cloud base IDE to create my blog. you can sign up for a free account and create a container.
https://codeanywhere.com/dashboard → create a new project
Add a project name:
Now provide a name to your project and select Ruby on rails Ubuntu 16.04 system and click create
Once completed you will see something like this: with the container and URL you will need to access your site in development. To access this page again you will need to right click on your project(example: demoproject) and click info.
You should see this page again.
Right click on the project and start a terminal by click ssh terminal
Environment Setup and Configuration.
- Check RVM version rvm — version and get stable with command rvm get stable
rvm --version
2. Check your ruby version ruby — version (dash dash), RVM install 3.0.0
ruby --version
Webpacker needs newer version of node in rails 6. currently in our system the node we have is lower than 12 so we need greater than that.
Lets check and install latest version of node.
COMMAND: NVM LS-REMOTE
nvm ls-remote
This should give us a list and point us to the latest version.
Run command nvm install <LATEST VERSION>
nmv install 14.15.5
Install yarn —
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
add to list
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.listsudo apt update && sudo apt install yarn
run the following command
gem install rails
Creating a Blog skeleton in rails and configure to be able to view the starter page.
Let create a blog with the following command.
- Rails new command to create a blog… you can name your blog anything. I am going to call my blog
rails new blog
2. Lets CD into the Blog folder
Before we can start our Server we need to make a configuration change to be able to view our page in code anywhere.
Refresh your blog and then lets cd into blog folder
cd blog
Configuration: go to Config -> development rb and on the bottom copy the access link and add the link to your development.rb file towards the bottom.
a) config.hosts << “kheblog-randi290.codeanyapp.com”
config.hosts << “kheblog-randi290.codeanyapp.com”
Now lets start the rails server to make sure everything is up and ready for us to start…..
in your terminal (project -> right click- > SHH terminal → navigate to blog if you are not already there….
rails s — binding=0.0.0.0
check server running
Test by click on the link which can be found by right clicking on project and click info as mentioned previously above. This is the same link you used to enable access within your development.rb file above.
YAH!! We are online…. If you have any issue please add comments and i can assist in resolving your issue.