GRZ Updated
Gaming Review Zone (GRZ - Pronounced as Gears) is a simple web app where you can create reviews about video games. I've created and built this project with Sinatra so I thought upgrading the code in Rails would be great idea!
The Process
I worked with Ruby on Rails along with ActiveRecord
. I used devise
to create my User
class which added all of my user authentication.
I've created my Reviews
and Games
class and formed the has_many
, belongs_to
, and has_many_through
relationship between them. I've added validations and a custom validation.
# app > models > game.rb
has_many :reviews
has_many :users, through: :reviews
validates :title, presence: true, uniqueness: true
validates :title, length: { maximum: 35 }
validate :is_title_case
def is_title_case
if title.split.any?{|w|w[0].upcase != w[0]}
errors.add(:title, "must be in title case")
end
end
I've added Omniauth
to the authentication system so users can be able to sign in with Google. I've added all of the necessary nested and non-nested routes in the config/routes directory.
# nested route
resources :games do
resources :reviews, only: [:new, :show]
end
Overall
Being so comfortable with Sinatra, transitioning to Rails was a little tough. After working on this project, I was able to grasp it more. There's still so much to learn, but once again I've proved to myself that I can stick through.
JavaScript here I come! ✨
Top comments (0)