How to use Rails 4 strong parameters with has_many :through association?

Keep in mind that the name you give to your strong parameters (employees, employee_ids, etc.) is largely irrelevant because it depends on the name you choose to submit. Strong parameters work no “magic” based upon naming conventions. The reason https://gist.github.com/leemcalilly/a71981da605187d46d96 is throwing an “Unpermitted parameter” error on ’employee_ids’ is because it is expecting an array … Read more

Ruby on Rails – “Add ‘gem sqlite3” to your Gemfile”

In my case, this error “Specified ‘sqlite3’ for database adapter, but the gem is not loaded. Add gem ‘sqlite3’ to your Gemfile.” message showed up, when I ran rails server right after I generated a fresh rails app. It was with Rails version 4.1.16 (Ruby version 2.3.1) gem ‘sqlite3’, ‘~> 1.3.0’ This line in Gemfile … Read more

strong parameters permit all attributes for nested attributes

The only situation I have encountered where permitting arbitrary keys in a nested params hash seems reasonable to me is when writing to a serialized column. I’ve managed to handle it like this: class Post serialize :options, JSON end class PostsController < ApplicationController … def post_params all_options = params.require(:post)[:options].try(:permit!) params.require(:post).permit(:title).merge(:options => all_options) end end try … Read more

Bootstrap 3+Rails 4 – Certain Glyphicons not working

I had the same problem and found a solution. Full credit goes to Eric Minkel, who wrote a detailed blog post on the topic. I would highly suggest reading it for further reasoning. Edit app/assets/stylesheets/application.css by adding: *= require bootstrap Edit app/assets/javascripts/application.js by adding: //= require bootstrap In config/application.rb, add the following after class Application … Read more