Category Archives: RubyonRails

adding a user profile on sign up with Devise

I have user registration form however to keep it simple I don’t want the user to have to enter lots of details during the initial registration, however want to have them complete a profile page. I wanted the profile to be created on registration so set up a has_one relationship in my model: class User… Read More »

has_many through & fields_for in rails

Took me a while to work this one out but let me paint the scene. I have 3 models as follows: class Student < ApplicationRecord has_many :education_records has_many :qualifications, through: :education_records accepts_nested_attributes_for :qualifications end class EducationRecord < ApplicationRecord belongs_to :student belongs_to :qualification has_many :qualifications has_many :students end class Qualification < ApplicationRecord has_many :education_records has_many :students,… Read More »

Setting up Spec for rails testing

I’m getting to grips with RSpec for testing and getting to grips with some of it’s functionality.  To play around with some of the features I’m building a side project of an employee database, nothing too fancy but just something that stores all the features of an employee, i.e. name, salary, email, location, phone number… Read More »

Bootstrap – Responsive Mobile

I was having trouble with bootstrap adapting to mobile as it was still rendering a full page on my iPhone.  If you have the same issue with your smartphone not showing the responsive layout ensure you have the code below in your header. <meta name=”viewport” content=”width=device-width, initial-scale=1, maximum-scale=1″ />

Testing Setup in Rails

Took me a little while to get my head around testing but thanks to the rails tutorial it’s starting to sink in.  Here’s how to make testing g a lot easier thanks to guard and mini-test reporters.  For the full guide head over to here, this is just so I remember it!

Heroku: Application Error

Just in case anyone else is receiving an ‘Application Error: An Error occurred in the application and your page could not be served’ error after pushing your rails project my fix was pretty simple. In the console I ran: $ heroku run rake db:migrate This gave me an error saying that because Heroku didn’t support SQLite3… Read More »