Forbes magazine logo Ranked Best Coding Bootcamps 2023

Questions and Answers

About 153 questions

ActionController::UnknownFormat for css files not found

You have to catch this error yourself. In application.rb class ApplicationController < ActionController::Base rescue_from ActionController::UnknownF ...

Asked on 7 February 2018

uninitialized constant ActionCable

Make sure you have require "action_cable/engine" in application.rb

Asked on 7 February 2018

Subscription class not found - Rails ActionCable

https://stackoverflow.com/questions/34756809/actioncable-channel-not-accessible-outside-rails-plugin

Asked on 7 February 2018

How to test specs with Time.now in Rspec

Use timecop gem! Or...Rail's default TimeHelper https://blog.pivotal.io/labs/labs/goodbye-timecop-hello-timehelpers

Asked on 7 February 2018

Precisions for Time.now in Rails

1.seconds or 1.second is only precise to the second, not milli-seconds

Asked on 7 February 2018

How to unsubscribe from ActionCable channel

client side rails 5.0 If you are using the javascript actioncable package. you can unsubscribe by calling the unsubscribe() function on the channel r ...

Asked on 7 February 2018

Disable Airbrake on development

In config/airbrake.rb, # New way Airbrake.configure do |c| c.environment = Rails.env c.ignore_environments = %w(development test) end Reference: ...

Asked on 7 February 2018

Commenting inside a .env file

Use hash "#" before a string of comments For example, in .env, # You can comment HereFOO=Bar

Asked on 7 February 2018

Upgrade from Rails 4.2 to 5.0

http://weblog.rubyonrails.org/2016/6/30/Rails-5-0-final/#yay http://railsapps.github.io/updating-rails.html

Asked on 7 February 2018

How to take screenshot in rails

https://github.com/seleniumhq/selenium https://github.com/flavorjones/chromedriver-helper http://jjbohn.info/blog/2013/07/31/how-to-take-a-screenshot- ...

Asked on 7 February 2018

Postgres JSON vs. Rails Serializer

See http://pjkh.com/articles/postgresql-json-vs-rails-serialize/

Asked on 7 February 2018

Can you serialize with Struct in Rails?

Yes, you can serialize with Struct and OpenStruct, but you also need to create the Structto store it.

Asked on 7 February 2018

Session gets logged out randomly in Rails

Make sure your cookie is set to be permanent, so that it doesn't get deleted when you exit the browser.

Asked on 7 February 2018

How to add more attributes after params

class UsersController < ApplicationController def update user = User.first user.update(user_params) end private def user_params ...

Asked on 7 February 2018

.count vs .length vs .size in Rails

http://web.archive.org/web/20100210204319/http://blog.hasmanythrough.com/2008/2/27/count-length-size If you set up a counter cache on the association ...

Asked on 7 February 2018

after_create vs after_save in Rails

after_create - works once, only after the record is first created. after_save - works every time when you "save" a record; a record can be "saved" wit ...

Asked on 7 February 2018

Store arrays or hashes in Rails ActiveRecord

If you have an attribute that needs to be saved to the database as an object (hash, json or array), and retrieved as the same object, then specify the ...

Asked on 7 February 2018

Show "relative time" in Rails?

Like "sent 2 mins ago" time_ago_in_words(timestamp) Example: timestamp = Time.nowtime_ago_in_words(timestamp)

Asked on 7 February 2018

.new vs. .save v.s. .create

In Ruby On Rails, active record provides .new & .save v.s. .create, what is the difference? Answer Although it is correct that create calls new and t ...

Asked on 7 February 2018

Angular AnchorScroll and scrollTo reloads page when scroll to a div hash

So I am using anchorScroll and scrollTo to allow user to scroll to different sections of a page, however, whenever the scrollTo link is clicked, the p ...

Asked on 7 February 2018

Trusted by

Students and instructors from world-class organizations

Imperial College London
Carnegie Mellon University
City University of Hong Kong
Hack Reactor
Cisco Meraki
University of Oxford
Swift
Bazaarvoice
Waterloo
Uber
AtlanTech
Tumblr
Boston College
Bombardier Aerospace
University of St. Andrews
New York University
Minerva Schools at KGI
Merrill Lynch
Riot Games
JP Morgan
Morgan Stanley
Advanced Placement®
Google
KPMG
The University of Hong Kong
University of Toronto
SCMP
Moat
Zynga
Hello Toby
Deloitte
Goldman Sachs
Yahoo
HSBC
General Assembly
Tesla
McGill University
Microsoft

Join the upcoming Cohort #89

Enroll for May 6th, 2024