refinery / refinerycms-news

News Plugin for Refinery CMS
http://www.refinerycms.com
MIT License
121 stars 120 forks source link

Can't mass-assign protected attributes: locale #90

Closed julesce closed 12 years ago

julesce commented 12 years ago

Hi guys,

I've got a fresh install of Refinery 2.0.3, and am getting this error when trying to create a new article in the admin section:

ActiveModel::MassAssignmentSecurity::Error in Refinery/news/admin/items#new

Showing c:/Ruby192/lib/ruby/gems/1.9.1/gems/refinerycms-news-2.0.0/app/views/refinery/news/admin/items/_form.html.erb where line #15 raised:

Can't mass-assign protected attributes: locale Extracted source (around line #15):

<div class='field'>
 <%= f.label :title %>
 <%= f.text_field :title, :class => "larger widest" %>
</div>

Thanks in advance for any help :-)

parndt commented 12 years ago

I'll release a new version shortly, thanks!

robbied72 commented 12 years ago

hi, has there been a fix done for this yet? Thanks Robbie

mitfik commented 12 years ago

fix was merged from #84 and #85 so it should works already on master branch, if not give me know I will check and fix again ;)

parndt commented 12 years ago

I just need to push a new gem

Please remind me it this isn't done in 3 hours' time

parndt commented 12 years ago

Fixed by http://rubygems.org/gems/refinerycms-news/versions/2.0.1

julesce commented 12 years ago

Thanks! :-)

krakatoa commented 12 years ago

Hi! Is it me or this happens again in 2.0.4 ? thnx!!

mitfik commented 12 years ago

Yep it seems that bug back ;)

@parndt why did You change it again?

aghyad commented 12 years ago

I have refinerycms 2.0.4 and I created a custom engine. When I used it to add a record it threw the same error! Any solution that also applies to custom engines?

more details on my error:

ActiveModel::MassAssignmentSecurity::Error in Refinery::Pianos::Admin::PianosController#update

Can't mass-assign protected attributes: dimensions, manufactured_on(1i), manufactured_on(2i), manufactured_on(3i), upright, photo_id, description

ugisozols commented 12 years ago

@krakatoa, @mitfik I can't reproduce this bug and I'm pretty sure @parndt hasn't changed anything.

@aghyad the error explanation is right in front of you. Add all of these attributes to attr_accessible list in pianos model.

aghyad commented 12 years ago

@ugisozols I already did and it worked of course, but I am asking if it is possible to include the solution in the engine so it avoids generating this issue again when generating custom engines. For now, my advice to everyone is to just go to your added engine's model and add the attributes causing the error to raise.

ugisozols commented 12 years ago

@aghyad the best option would be to use 2-0-stable branch of refinery's github repo as it contains this fix.

# in Gemfile
gem "refinerycms", :git => "https://github.com/resolve/refinerycms.git",
                   :branch => "2-0-stable"
mitfik commented 12 years ago

@ugisozols here is link to his changes: https://github.com/resolve/refinerycms-news/commit/d49180fa788c0b4908e4707aa3afa32ba38db998 It was made few moments after he merge my fix for this bug. I do not know maybe he find out some other solution for this problem or maybe this cause some other problmes. But as You can see bug is back :)

ugisozols commented 12 years ago

As I said before I can't reproduce this issue and d49180fa788c0b4908e4707aa3afa32ba38db998 just removes unnecessary if...else so I'm not sure what's the real problem here.

mitfik commented 12 years ago

The problem is not unnecessary if ... else but namespacing of this class and if ... else statement is just to avoid error when class is not defined yet.