Skip to content

Instantly share code, notes, and snippets.

@mgidea
mgidea / strong_params.rb
Last active January 4, 2016 04:29
quick way to work through models with lots of attributes. assume :user accepts_nested_attributes_for :profile
This is in application_controller but could be in a module
NON_FORM_PARAMS = [:id, :created_at, :updated_at]
def permitted_params(model)
model.column_names - NON_FORM_PARAMS
end
def nested_destroy(model)
permitted_params(model) + [:destroy, :id]
end
@mgidea
mgidea / edit_spec.rb
Last active December 24, 2015 13:59
initial spec page
require 'spec_helper'
feature "User edits ther review", %Q{
As an author of a review
I want to be able to edit my review
} do
# Acceptance Criteria
# * Only the author of a review can edit a review
# * non-authors will not see a link to edit