Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Created April 24, 2013 16:23
Show Gist options
  • Save telagraphic/5453453 to your computer and use it in GitHub Desktop.
Save telagraphic/5453453 to your computer and use it in GitHub Desktop.
def feed_me(source, subtopic)
@feed = current_user.feeds.build(model_id: source.id, model_name: source.class.to_s, subtopic_id: subtopic.id)
@feed.save
end
ActiveModel::MassAssignmentSecurity::Error in ScreensController#create
Can't mass-assign protected attributes: subtopic_id
Rails.root: /Users/telagraphic/Documents/programming/rails_projects/codebase
Application Trace | Framework Trace | Full Trace
app/controllers/application_controller.rb:9:in `feed_me'
app/controllers/screens_controller.rb:20:in `create'
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"Lirq7qJa2mcgmcnxO54pordlxp3LACg7OgC9bbr1YWQ=",
"screen"=>{"description"=>"asdfasdf"},
"commit"=>"New Screen",
"subtopic_id"=>"14"}
class Feed < ActiveRecord::Base
attr_accessible :model_id, :model_name, :subtopic_id
belongs_to :user
belongs_to :subtopic
end
def create
@subtopic = Subtopic.find_by_id(params[:subtopic_id])
@screen = @subtopic.screens.build(params[:screen])
if @screen.save
feed_me(@screen, @subtopic)
redirect_to [topic, @subtopic]
else
render 'new'
end
end
class Subtopic < ActiveRecord::Base
attr_accessible :title
has_many :feeds
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment