Rails: Unpermitted parameter in Rails 5

It’s not the inflection of the word “criteria” that’s giving you problems (although you can add a custom inflector to get the singular and plural versions you prefer if you really want). The issue is that you have to explicitly permit the fields of nested objects. Change your current params: params.require(:project).permit(:name, project_criteria: [] ) To … Read more

Rails: How to implement protect_from_forgery in Rails API mode

Here’s what the issue was: Rails 5, when in API mode, logically doesn’t include the Cookie middleware. Without it, there’s no Session key stored in a Cookie to be used when validating the token I passed with my form. Somewhat confusingly, changing things in config/initializers/session_store.rb had no effect. I eventually found the answer to that … Read more

Change the default value for table column with migration

You have to check which version of ActiveRecord you are using. According to your command rake db:migrate you are still on Ruby on Rails 4.2 or earlier. If you are on ActiveRecord up to 4.2 (change_column_default 4.2.9), there is no from/to option and you can define only the new default option as param. class ChangeDefaultvalueForHideSeasonSelector … Read more

ActionCable.server.broadcast from the console

The default behavior for ActionCable in development mode is to use the async adapter, which operates within the same process only. For inter-process broadcasting, you will need to switch to the redis adapter. To enable redis in development mode, you will need to edit config/cable.yml: redis: &redis adapter: redis url: redis://localhost:6379/1 production: *redis development: *redis … Read more

require_tree argument must be a directory in a Rails 5 upgraded app

I finally figured it out. So because I am doing the upgrade, RailsDiff didn’t tell me that I was missing something. So the error message wasn’t incorrect, however, what I forgot to do was to create an empty directory. In my app/assets/javascripts/cable.js, I had the following: //= require_tree ./channels However, I forgot to actually create … Read more

Is DatabaseCleaner still necessary with Rails system specs?

You do not need the DatabaseCleaner gem. Here’s a quick summary of steps you need: Remove capybara-selenium gem and database_cleaner gem Add selenium-webdriver gem Make sure you are using Rails 5.1.5 or later. Earlier versions of Rails 5.1 had a defect in ActionDispatch::SystemTesting::Server that caused problems (fixed here). In your rails_helper file, set config.use_transactional_fixtures = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)