Rails Engage!错误(无法批量分配受保护的属性:用户) [英] Rails Engage! Error (Can't mass-assign protected attributes: user)

查看:90
本文介绍了Rails Engage!错误(无法批量分配受保护的属性:用户)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在安装,在底部找到完整的堆栈跟踪)





因此,我开始使用Google搜索,并且看到如下所示的内容:



我已经将attr_accessible:user添加到了我的用户模型中,但那不起作用。



这是我的用户模型:





另外,我看不到我如何访问参与模型等,请看这里是我的目录:





有人知道如何解决这个问题吗?如果您需要其他信息,请告诉我,我会提供屏幕截图。

编辑#1 - 添加应用程序控制器图片和完整堆栈跟踪 / p>

这是唯一能看到任何与Engage!in控制器相关的东西(我目前没有用户控制器)



以下是完整的堆栈跟踪:


new'activerecord(3.2.11)lib / active_record / reflection。 rb:183:in< / code> build_association'activerecord(3.2.11)lib / active_record / associations / association.rb:233:in< code> build_record'activerecord(3.2.11)lib / active_record / associations / collection_association。 rb:434:在create_record中的< / code>块中activerecord(3.2.11)lib / active_record / associations / collection_association.rb:149:在交易中的< code>块中activerecord(3.2.11)lib / active_record / connection_adapters / abstract / database_statements.rb:192:in< / code> transaction'activerecord(3.2.11)lib / active_record / transactions.rb:208:in< code> transaction'activerecord(3.2.11)lib / active_record /关联/ collection_association.rb:148:在< / code>事务中'activerecord(3.2.11)lib / active_record / associations / collection_association.rb:433:in< code> create_record' activerecord(3.2.11)lib / active_record / associations / collection_proxy.rb:46:在< code> create'中创建'activerecord(3.2.11)lib / active_record / associations / collection_association.rb:119:< / code> (< / code> create'actionpack(3.2.11)lib / action_controller / metal / implicit_render.rb:4:in< code> send_action' actionpack(3.2.11)lib / abstract_controller / base.rb:167:in< / code> process_action'actionpack(3.2.11)lib / action_controller / metal / rendering.rb:10:in< code> process_action'actionpack 3.2.11)lib / abstract_controller / callbacks.rb:18:在process_action中的< / code>块中activesupport(3.2.11)lib / active_support / callbacks.rb:426:在block中_run__2010401100414174750__process_action__2035169522325419882__callbacks'>



块中的active / support / notifications.rb:123:in 20:in< code> instrument'activesupport(3.2.11)lib / active_support / notifications.rb:123:in< / code> instrument'actionpack(3.2.11)lib / action_controller / metal / instrumentation.rb:29: in< code> process_action'actionpack(3.2.11)lib / action_controller / metal / params_wrapper.rb:207:in< / code> process_action'activerecord(3.2.11)lib / active_record / railties / controller_runtime.rb:18: in< code> process_action'actionpack(3.2.11)lib / abstract_controller / base.rb:121:in< / code> process'actionpack(3.2.11)lib / abstract_controller / rendering.rb:45:in< code> (3.2.11)lib / action_controller / metal / rack_delegation.rb:14:在< code>调度中的进程'actionpack 'actionpack(3 (3.2.11)lib / action_dispatch / routing / route_set.rb:73:in< code> call'actionpack(3.2.11)lib / action_controller / metal.rb:246:在< / code> .11:lib / action_dispatch / routing / route_set.rb:73:in< / code>调度'actionpack(3.2.11)lib / action_dispatch / routing / route_set.rb:36:in< code> call'journey(1.0 .4)lib / journey / router.rb:68:在调用'journey(1.0.4)lib / journey / router.rb:56:in< code>每个'旅程中的(< / code> )lib / journey / router.rb:56:in< / code> call'actionpack(3.2.11)lib / action_dispatch / routing / route_set.rb:601:in< code> call'railties(3.2.11)lib /rails/engine.rb:479:in</code>call'railties(3.2.11)lib / rails / railtie / configurable.rb:30:in< code> method_missing'journey(1.0.4)lib / journey /router.rb:68:in</code> block in call'journey(1.0.4)lib / journey / router.rb:56:in< code> each'journey(1.0.4)lib / journey / router .rb:56:在< / code> call'actionpack(3.2.11)lib / action_ dispatch / routing / route_set.rb:601:in call'warden(1.2.1)lib / warden / manager.rb:35:在调用中的< / code> warden / manager.rb:34:in< code> catch'warden(1.2.1)lib / warden / manager.rb:34:in< / code> call'actionpack(3.2.11)lib / action_dispatch / middleware /调用'rack(1.4.3)lib / rack / etag.rb:23:在< / code>调用'rack(1.4.3)lib / rack / conditionalget.rb中调用'best_standards_support.rb:17:< code> 35:in< code> call'actionpack(3.2.11)lib / action_dispatch / middleware / head.rb:14:in< / code> call'actionpack(3.2.11)lib / action_dispatch / middleware / params_parser.rb: 21:在`call'>



.11)lib / action_dispatch / middleware / flash.rb:242:in< code> call (1.4.3)lib / rack / session / abstract / id.rb:205:在< code>调用'actionpack(3.2.11)lib / action_dispatch / middleware / cookies .rb:341:在< / code>调用中'activerecord(3.2.11)lib / active_record / query_cache.rb:64:in< code> call'activerecord(3.2.11)lib / active_record / connection_adapters / abstract / connection_pool .rb:479:in< / code> call'actionpack(3.2.11)lib / action_dispatch / middleware / callbacks.rb:28:在调用'activesupport(3.2.11)中的< code>块中'/ active_support / callbacks .rb:405:in< / code> _run__4377122496359715927__call__4128007891844716680__callbacks'activesupport(3.2.11)lib / active_support / callbacks.rb:405:in< code> __ run_callback'activesupport(3.2.11)lib / active_support / callbacks.rb:385 :in< / code> _run_call_callbacks'activesupport(3.2.11)lib / active_support / callbacks.rb:81:in< code> run_callbacks'actionpack(3.2.11)lib / action_dispatch / middleware / callbacks.rb:27:in< ; / code> call'actionpack(3.2.11)lib / action_dispatch / middleware / reloader.rb:65:in< code> call'actionpack(3.2.11)lib / action_dispatch / middleware / remote_ip.rb:31:in< ; /代码> CAL (3.2.11)lib / action_dispatch / middleware / show_exceptions.rb:56:在< / code>中调用'actionpack(3.2.11)lib / action_dispatch / middleware / debug_exceptions.rb:16:< code>调用'railties(3.2.11)lib / rails / rack / logger.rb:32:in< code> call_app'railties(3.2.11)lib / rails / rack / logger.rb:16:in< / code> block in call'activesupport(3.2.11)lib / active_support / tagged_logging.rb:22:在< code>标记的'railties(3.2.11)lib / rails / rack / logger.rb:16:in< / code>调用'actionpack(3.2.11)lib / action_dispatch / middleware / request_id.rb:22:in< code> call'rack(1.4.3)lib / rack / methodoverride.rb:21:in< / code> call' rack(1.4.3)lib / rack / runtime.rb:17:在< code> call'activesupport(3.2.11)lib / active_support / cache / strategy / local_cache.rb:72:in< / code> call' rack(1.4.3)lib / rack / lock.rb:15:在< code> call'actionpack(3.2.11)lib / action_dispatch / middleware / static.rb:62:in< / code> call'railties( 3.2.11)lib / rails / engine.rb:479:in< c (< / code> call'rack(1.4.3)lib / rack / content_length.rb:14:在< code> call'中调用'railties(3.2.11)lib / rails / application.rb:223: (< code> server> lib / rack / handler / webrick.rb:59:in< / code> call'rack(1.4.3)lib / rails / rack / log_tailer.rb: /Users/johndoe/.rbenv/versions/1.9.3-p327-perf/lib/ruby/1.9.1/webrick/httpserver.rb:138:in</code>service'/Users/johndoe/.rbenv/versions /1.9.3-p327-perf/lib/ruby/1.9.1/webrick/httpserver.rb:94:in< code> run'/Users/johndoe/.rbenv/versions/1.9.3-p327-perf/ lib / ruby​​ / 1.9.1 / webrick / server.rb:191:在< / code>块中的start_thread'>



编辑#2 - 添加互动环境:

另外,我们还安装了Devise(和OmniAuth,我相信...)。因此,我们有current_user,但我不知道我们是否有用户名或电子邮件方法,除非标准符合Devise或



编辑#3 - 正如Geoff所建议的,我查看了topics_controller的第46行。

@ topic.votes.create(:user => engage_current_user)

解决方案

这是Engage之一!这里的开发者我可以看到Engage有两个问题!

我们已经找到了第一个解决方案(您已经使用 attr_accessible:user >解决了这个问题) ),所以期待一个Rubygems更新。



第二个(主题实际上并未显示在索引页上的事实)与cancan gem中的更改相关联。我们仍然需要找出解决这个问题的最佳方法,但是一个快速的解决方法是将Genericfile中的cancan版本锁定如下: gem'cancan','1.6.7'

我们会在Rubygems上通知您何时可以解决这些问题。



干杯!

I'm working on installing Engage!

I followed the installation instructions found here: http://engagecsm.com/readme

Installation steps I did:

  1. Add Engage! to the application's Gemfile: gem 'engagecsm'.
  2. Install it: bundle install.
  3. Run the generator: rails generate engage User.
  4. Run the migrations: rake db:migrate.

Now, I can go to localhost:3000/engage

This is what shows up:

Now, when I hit "Create Topic", nothing happens on the site. I look at my rails server console and I see this: (Easier to view here http://i.stack.imgur.com/xKBER.png, full stack trace found at the bottom)

So I start googling, and I see things like this:

I already added attr_accessible :user to my User model, but that didn't work.

Here's my User model:

Also, I can't see how I have access to Engage models and such, see here's my directory:

Does anyone know how to fix this? If you want any other information, please tell me and I'll provide screenshots.

Any help is greatly appreciated. Thank you!

EDIT #1 - Adding application controller picture and full stack trace

This is the only place I can see anything with Engage! in controllers (I don't have a User controller at this time)

Here's the full stack trace:

EDIT #2 - Add engage environment:

Also, we have Devise (and OmniAuth I believe...) installed. Therefore, we have "current_user", but I don't know if we have a "username" or "email" method, unless that comes standard with Devise or something

EDIT #3 - As Geoff suggested, I looked at line 46 of the topics_controller. That line is the following:

@topic.votes.create(:user => engage_current_user)

解决方案

it's one of Engage! developers here. I can see there are two problems with Engage! described above.

We have found the solution to the first (the one that you have solved with attr_accessible :user), so expect a Rubygems update soon.

The second (the fact that topics are not actually displayed on the index page) is connected with the changes in the cancan gem. We still have to figure out the best way to approach this, but a quick workaround is to lock the cancan version in the Gemfile as follows: gem 'cancan', '1.6.7'.

We will let you know when the updates addressing these issues will be available at Rubygems.

Cheers!

这篇关于Rails Engage!错误(无法批量分配受保护的属性:用户)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆