Rails 4.0 with Devise. Nested attributes Unpermited parameters

config/routes.rb Create your own registration controller like so … (see Devise documentation for the details of overriding controllers here …) … which is more elegant way as opposed to doing it via the ApplicationController devise_for :users, controllers: {registrations: ‘users/registrations’} app/controllers/users/registrations_controller.rb Override the new method to create a Profile associated with the User model as below … Read more

Rails has_many through form with checkboxes and extra field in the join model

Looks like I figured it out! Here’s what I got: My models: class Product < ActiveRecord::Base has_many :categorizations, dependent: :destroy has_many :categories, through: :categorizations accepts_nested_attributes_for :categorizations, allow_destroy: true validates :name, presence: true def initialized_categorizations # this is the key method [].tap do |o| Category.all.each do |category| if c = categorizations.find { |c| c.category_id == category.id … Read more

Rails nested form with has_many :through, how to edit attributes of join model?

Figured out the answer. The trick was: @topic.linkers.build.build_article That builds the linkers, then builds the article for each linker. So, in the models: topic.rb needs accepts_nested_attributes_for :linkers linker.rb needs accepts_nested_attributes_for :article Then in the form: <%= form_for(@topic) do |topic_form| %> …fields… <%= topic_form.fields_for :linkers do |linker_form| %> …linker fields… <%= linker_form.fields_for :article do |article_form| %> … Read more