overriding user.rb

1 view
Skip to first unread message

Ansar.ich

unread,
Nov 4, 2009, 1:40:08 AM11/4/09
to CommunityEngine
I overrided user.rb by just creating new file user.rb with class
User<ActiveRecord::Base end. I get this error when go from Community
to My Profile and then to site_index:

Rendering base/site_index
←[4;36;1mUser Load (0.0ms)←[0m ←[0;1mSELECT * FROM `users` WHERE
(`users`.`id` = 1) LIMIT 1←[0m
←[36;2mvendor/plugins/community_engine/plugins/paginating_find/lib/
paginating_find.rb:103:in `find'←[0m
←[36;2mvendor/plugins/community_engine/app/models/user.rb:93:in
`find'←[0m
←[36;2mvendor/plugins/community_engine/lib/authenticated_system.rb:
15:in `logged_in?'←[0m
←[36;2mapp/views/base/site_index.html.haml:3:in
`_run_haml_app47views47base47site_index46html46haml'←[0m
←[36;2mvendor/plugins/community_engine/lib/
localized_application.rb:25:in `set_locale'←[0m
←[36;2mvendor/plugins/community_engine/lib/
flash_session_cookie_middleware.rb:14:in `call'←[0m
←[36;2mvendor/plugins/community_engine/lib/
flash_session_cookie_middleware.rb:14:in `call'←[0m
←[4;35;1mUser Load (0.0ms)←[0m ←[0mSELECT * FROM `users` WHERE
(`users`.`id` = 1) ←[0m
←[35;2mvendor/plugins/community_engine/plugins/paginating_find/lib/
paginating_find.rb:103:in `find'←[0m
←[35;2mvendor/plugins/community_engine/app/models/user.rb:93:in
`find'←[0m
←[35;2mvendor/plugins/community_engine/app/views/posts/
_post.html.haml:6:in
`_run_haml_vendor47plugins47community_engine47app47views47posts47_post46html46haml_locals_object_post_post_counter'←
[0m
←[35;2mapp/views/base/site_index.html.haml:17:in
`_run_haml_app47views47base47site_index46html46haml'←[0m
←[35;2mvendor/plugins/community_engine/lib/
localized_application.rb:25:in `set_locale'←[0m
←[35;2mvendor/plugins/community_engine/lib/
flash_session_cookie_middleware.rb:14:in `call'←[0m
←[35;2mvendor/plugins/community_engine/lib/
flash_session_cookie_middleware.rb:14:in `call'←[0m

ActionView::TemplateError (You have a nil object when you didn't
expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?) on line #6 of vendor/
plugins/community_engine/app/views/posts/_post.html.haml:
3: = link_to post.title, user_post_path(post.user, post), :rel =>
'bookmark'
4:
5: .vcard.author
6: %h5
7: %a{:href=>"#{user_post_path(post.user,
post)}", :class=>"photo", :rel=>"bookmark"}
8: =image_tag((post.first_image_in_body ||
post.user.avatar_photo_url
(:thumb)), :alt=>"", :width=>"50", :height=>"50")
9:

generated code (actionpack (2.3.2) lib/action_controller/routing/
route.rb:160):5:in `generate_raw'
(eval):16:in `user_post_path'
vendor/plugins/community_engine/app/views/posts/_post.html.haml:
6:in
`_run_haml_vendor47plugins47community_engine47app47views47posts47_post46html46haml_locals_object_post_post_counter'
haml (2.2.1) lib/haml/helpers/action_view_mods.rb:11:in `render'
haml (2.2.1) lib/haml/helpers.rb:77:in `non_haml'
haml (2.2.1) lib/haml/helpers/action_view_mods.rb:11:in `render'
app/views/base/site_index.html.haml:17:in
`_run_haml_app47views47base47site_index46html46haml'
haml (2.2.1) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (2.2.1) lib/haml/helpers/action_view_mods.rb:13:in `render'
haml (2.2.1) lib/sass/plugin/rails.rb:19:in `process'

Rendered rescues/_trace (140.0ms)
Rendered rescues/_request_and_response (16.0ms)
Rendering rescues/layout (internal_server_error)









Jim Ruther Nill

unread,
Nov 4, 2009, 1:47:41 AM11/4/09
to communi...@googlegroups.com
add this at the top of app/models/user.rb

require_dependency "#{RAILS_ROOT}/vendor/plugins/community_engine/app/models/user.rb"
--
"We do not believe in ourselves until someone reveals that deep inside us is valuable, worth listening to, worthy of our trust, sacred to our touch." - E. E. Cummings

Ansar.ich

unread,
Nov 4, 2009, 2:01:36 AM11/4/09
to CommunityEngine
It did not help. It always works just once, after restarting mongrel
and refreshing the page.

Jim Ruther Nill

unread,
Nov 4, 2009, 2:20:08 AM11/4/09
to communi...@googlegroups.com
try adding this in your development config file.

config.after_initialize do
  ActiveSupport::Dependencies.load_once_paths = ActiveSupport::Dependencies.load_once_paths.select {|path| (path =~ /(community_engine|asset_packager)/).nil? }
end



On Wed, Nov 4, 2009 at 3:01 PM, Ansar.ich <anzor.i...@gmail.com> wrote:

It did not help. It always works just once, after restarting mongrel
and refreshing the page.




Ansar.ich

unread,
Nov 4, 2009, 3:34:12 AM11/4/09
to CommunityEngine
Thank you sooooo much!
I added this

config.after_initialize do
ActiveSupport::Dependencies.load_once_paths =
ActiveSupport::Dependencies.load_once_paths.select {|path| (path =~ /
(community_engine|asset_packager)/).nil? }
end

to development config file and removed require_dependency "#
{RAILS_ROOT}/vendor/plugins/community_engine/app/models/user.rb" from
user.rb.
Could you please write why this heppens?

Again thanks a lot



On Nov 4, 1:20 pm, Jim Ruther Nill <jvn...@gmail.com> wrote:
> try adding this in your development config file.
>
> config.after_initialize do
>   ActiveSupport::Dependencies.load_once_paths =
> ActiveSupport::Dependencies.load_once_paths.select {|path| (path =~
> /(community_engine|asset_packager)/).nil? }
> end
>

Bruno Bornsztein

unread,
Nov 4, 2009, 9:08:03 AM11/4/09
to communi...@googlegroups.com
Which version of CE are you on? The latest version includes that
after_initialize block automatically, so you shouldn't have to include
it.

Also, just for the record, using require_dependecy is not necessary
(Desert should handle mixing the CE user model for you).

Anzor Israilov

unread,
Nov 4, 2009, 12:53:18 PM11/4/09
to communi...@googlegroups.com
I am using 4 months old version (don't know the name). Recently I downloaded latest one, but I just don't to move to it because of deadlines issue.

Luca Faggioli

unread,
Nov 4, 2009, 12:57:20 PM11/4/09
to communi...@googlegroups.com
Hi Anzor

you can find your current version looking inside vendor/plugins/community_engine/about.yml

luca
--
Luca Faggioli
Openliven Srl
follow me on Twitter: http://twitter.com/lfaggioli
Reply all
Reply to author
Forward
0 new messages