need some help with some associations in my rails app. Get a "can't mass-assign protected attributes: rss_readers" warning and don't figured out what's the problem.
class Scraper < ActiveRecord::Base
attr_accessible :name, :link, :rss_reader_attributes
has_one :rss_reader
accepts_nested_attributes_for :rss_reader
And the accociation:
class RssReader < ActiveRecord::Base
attr_accessible :title, :address, :content
belongs_to :scraper
At the rails console its works fine.
> scraper = Scraper.new
> scraper.build_rss_reader
> scraper.attributes={:rss_reader_attributes=>{:address => "asdsad"}}
But in controller i get the warning.
def new
@scraper = Scraper.new
@scraper.build_rss_reader
end
def create
@scraper = Scraper.new(params[:scraper])
@scraper.build_rss_reader
if @scraper.save
redirect_to :show
else
render :new
end
And thats the new view
<%= form_for(@scraper) do |f| %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<%= f.fields_for(@scraper.rss_reader) do |rss| %>
<div class="field">
<%= rss.label :address %><br />
<%= rss.text_field :address %>
</div>
<% end %>
<div class="actions">
<%= f.submit "Submit" %>
</div>
<% end %>
I thougth that's all right but i get the warning. Anyone have an idea?
Thanks